Search code examples
javafile-ioiooperating-systembackspace

Backspace \b Chacacter Scope with regard to OS?


I looked very extensively, but I was unable to find information regarding the scope of the \b character in Java.

Note: I am using Eclipse, and know that it provides limited to no support for the character. (side question if you want to answer: looking for a console eclipse plugin supporting \b char)

I want to know two things:

Can I write the backspace char to file to delete previously written test? (I don't need to do this, but it reduces compatibility if I can't for my program)

Can I delete a newline (\r\n or either) character with \b?


Solution

  • Can I write the backspace char to file to delete previously written test?

    No.

    Can I delete a newline ("\r\n" or either) character with \b.

    No.

    The only situations where characters like \b will be interpreted like this are when you are writing to a screen, console or terminal.

    Characters written to a file are not treated like this.

    This is not a Java-specific restriction. Rather it is inherent in the way that operating systems1 handle writing data to files.


    1 - That is ... every OS that I have encountered.