[java] 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.

This question is related to java string character

The answer is


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


Or you could just perform a trim() on the string to handle the case when people use spaces instead of tabs (unless you are reading makefiles)


You can also use the tab character '\t' to represent a tab, instead of "\t".

char c ='t';
char c =(char)9;

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to string

How to split a string in two and store it in a field String method cannot be found in a main class method Kotlin - How to correctly concatenate a String Replacing a character from a certain index Remove quotes from String in Python Detect whether a Python string is a number or a letter How does String substring work in Swift How does String.Index work in Swift swift 3.0 Data to String? How to parse JSON string in Typescript

Examples related to character

Set the maximum character length of a UITextField in Swift Max length UITextField Remove last character from string. Swift language Get nth character of a string in Swift programming language How many characters can you store with 1 byte? How to convert integers to characters in C? Converting characters to integers in Java How to check the first character in a string in Bash or UNIX shell? Invisible characters - ASCII How to delete Certain Characters in a excel 2010 cell