I want to read from specific line and so on. For instance I want to read from line 8 and until it gets to the end of the file. Could someone teach me the proper way on how to program it?
My current code:
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
public class Arff {
public static void main(String[] args) throws FileNotFoundException {
File TextFile = new File("weather.nominal.arff");
Scanner reader = new Scanner(TextFile);
while(reader.hasNextLine()) {
String text = reader.nextLine();
String[] SplitData = text.split(" ");
if (SplitData[0].equals("@relation")) {
System.out.println(SplitData[1]);
System.out.println();
}
if (SplitData[0].equals("@attribute")) {
System.out.print(SplitData[1] + " ");
}
}
}
}
weather.nominal.arff
@relation weather.symbolic
@attribute outlook {sunny, overcast, rainy}
@attribute temperature {hot, mild, cool}
@attribute humidity {high, normal}
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}@data
sunny,hot,high,FALSE,no
sunny,hot,high,TRUE,no
overcast,hot,high,FALSE,yes
rainy,mild,high,FALSE,yes
rainy,cool,normal,FALSE,yes
rainy,cool,normal,TRUE,no
overcast,cool,normal,TRUE,yes
sunny,mild,high,FALSE,no
sunny,cool,normal,FALSE,yes
rainy,mild,normal,FALSE,yes
sunny,mild,normal,TRUE,yes
overcast,mild,high,TRUE,yes
overcast,hot,normal,FALSE,yes
rainy,mild,high,TRUE,no
Desired output:
weather.symbolic
outlook temperature humidity windy play
sunny,hot,high,FALSE,no
sunny,hot,high,TRUE,no
overcast,hot,high,FALSE,yes
rainy,mild,high,FALSE,yes
rainy,cool,normal,FALSE,yes
rainy,cool,normal,TRUE,no
overcast,cool,normal,TRUE,yes
sunny,mild,high,FALSE,no
sunny,cool,normal,FALSE,yes
rainy,mild,normal,FALSE,yes
sunny,mild,normal,TRUE,yes
overcast,mild,high,TRUE,yes
overcast,hot,normal,FALSE,yes
rainy,mild,high,TRUE,no