Hello all -
I am currently in JAVA I, so please bare with me. We are writing really simple programs, but i guess im a good student cause i always get done first and add more crap. Question is:
Is there a way to make a JAVA program (Class:main) delete output text that we tell our program to write?
Example: System.out.print("Hellol");
<I want to be able to make the program delete that>
System.out.print("Hello");
I know that I can always re-print this text to make it look like it deleted the word, but thats not my style. Please help, this is killing me.
Also, I often make the program look like it is 'typing' words, like this:
Thread.sleep(90);
System.out.print("H");
Thread.sleep(90);
System.out.print("e");
Thread.sleep(90);
System.out.print("l");
Thread.sleep(90);
System.out.print("l");
Thread.sleep(90);
System.out.print("o");
yup... too much time on my hands... anyways, I know there is an easier way to do this, with a String and a For loop perhaps, but i dont know what to type... Please help with this, also... Thanks.
I don't think once you have text on the console,you can delete it unless you reprint...there may be an option where you can run a dos command to clear the console....lets see if some one else understood your question better and come up with a solution..
Very system dependent but on some systems you can print backspace-space-backspace to delete the last character printed to a line and position the cursor to overwrite that position.
i wasnt planning on having the user input anything, im trying to have the program do basically all the work.... by the way i did find a loop for the 2nd question, thanks for thinkin about it anyways :-).
Khalid, I think you were closer the first time when you said about reprinting, ray ill try that clearing thing. Basically ive come up with so far is i can reprint everything ive already printed, leaving out a letter or word, making it seem like it has been deleted, but its not my style, again, i think it would look bad to be able to scroll up and the user say 'what a stupid trick'.... If you guys cant rack your minds for anything else, I understand, as my friend keeps telling me about how smart you are Khalid Ali. Thanks for the quick replies!
unless you write something that continously wait for an input, a java program will end as soon as you have printed a System.out statement.
This means you have no ability to go back and clear it...make sense..???
let me know if it does then we'll go from there...
Bookmarks