I've got a text file thats a database of sorts, however rather than the different columns being seperated by commas as would be preferred, it is formatted only through spacing. For example, the first few lines are something like
001 Paul 4
002 James 44
When I use BufferReader to parse lines of text it removes the excess spaces so that the resulting strings are
001 Paul 4
002 James 44
This presents a number of problems for me to distinguish the columns, because there are some places in the file that the columns aren't even separated by spaces, and the only way to tell that it's a new column is by knowing how many characters into the line it is. Is there anyway to read in the data from this text file without the spaces seemingly being removed? I tried using the read() function rather than readLine() to try and make sure that I got every byte, but still the extra spaces seemingly got deleted. My code is:
BufferedReader input = new BufferedReader(new FileReader("text.txt"));
String [] team = new String[15];
String line = "";
//read the first 15 lines
for (int i=0; i<15; i++) {
//607 is the number of characters in each of the lines.
for(int k=0; k<607; k++){
line+=(char)input.read();
}
team=line;
System.out.println(team[i]);
line="";
}
Thanks in advance for any help,
Repole
Edited by: Repole on Jul 30, 2008 8:10 PM
Edited by: Repole on Jul 30, 2008 8:10 PM