问题
Is there exist the opposite to the newline '\n'
character in Java which will move back to the previous line in the console?
回答1:
ASCII doesn't standardize a "line starve" or reverse line feed control character. Some character based terminals/terminal emulators recognize control code sequences that move the cursor up a line; these aren't Java-specific, and depend on your OS and configuration. Here's a starting point if you're using Linux: http://www.kernel.org/doc/man-pages/online/pages/man4/console_codes.4.html
回答2:
Java supports Unicode, which has the character "REVERSE LINE FEED" (U+008D). In Java it would be '\u008D'
(as a char
) or "\u008D"
(as a String
). Whether this would do what you want on a console, printout, or whatever, depends on the device. Java does not define any behavior for that character.
来源:https://stackoverflow.com/questions/13446412/is-there-oldline-character-in-java