I need to write a simple terminal-based program that should,
- Read some text from a file using FileReader wrapped in BufferedReader.
- Print this text to console and a user should be able to modify it.
- Upon Enter + S, the program should read the modified text and save it back to the original file.
To sum up, the idea is to write a text editor for Unix-like environments with no GUI.
However, I have problems with steps 2 and 3.
All the text that is printed by System.out is immutable. How can I change this behaviour?
How do I implement a key listener for Enter + S. I can easily do it with GUI, but what do I add a listener to in a console-based program? And on Enter the program should simply add a new line to the modified text. Also, how can I read text that has already been printed to the terminal?
P.S. I have to use JDK 1.4 so no access to Scanner and Console classes if it is any relevant. I also think that such a task would be impossible to do in Java, so you could suggest a solution in C/C++ After all, they did it somehow back in MS-DOS era.
Thank you!