I\'m working under Java and want to extract data according to column from a text file.
\"myfile.txt\" contents:
ID SALARY RANK
065 120
while((line = b.readLine()) != null) {
String[] columns = line.split(" ");
System.out.println("my first column : "+ columns[0] );
System.out.println("my second column : "+ columns[1] );
System.out.println("my third column : "+ columns[2] );
}
Now instead of System.out.println
, do whatever you want with your columns.
But I think your columns are separated by tabs
so you might want to use split("\t")
instead.