n0pe n0pe - 1 month ago 7
Java Question

Handling the TAB character in Java

I'm going through a configuration file with a RandomAccessFile reader. I have a configuration option which is one (1) tab away from the start of the line. When my reader gets this line, would I be able to just tell it to skip one character and then start reading, or does the tab character not work that way?

Example:

This is a line
This line has a tab


Let's say I've loaded the second line into my reader. If I'm playing with that String and I do
currentLine = currentLine.subString(1);


Would that give me:

currentLine = "This line has a tab";


Thanks for your help.

Answer

Yes the tab character is one character. You can match it in java with "\t".