String[] splitUp = line.split("\t");
This is the code and the string is this "John Doe 3.30 23123123"
The problem is at the end of Doe and after 3.30 those spaces are actually tabs. Now I have to split up this string by the tabs and \t and \t aren't working. Help
Here is more code:
while(scan.hasNextLine()){
String line = scan.nextLine();
String[] splitUp = line.split("\\t");
for(int i = 0; i < splitUp.length; i++){
System.out.println(splitUp[i]);
}
}
and I have a text file which is feeding in lines with tabs.
Answer:
if editing a .txt file with the java compiler IntelliJ then it replaces the \t char with the corresponding amount of spaces, therefore you cannot check for \t because it doesn't exist. you have to edit it in a regular text editor and all will be good.