Hey guys. I have a headache here as im new to Java. Ive tried searching, but found nothing that really helped me out. forgive a noob :)
Im trying to split a string from a textfile with the following format:
0 0 0 0 0 0 0 0 0 110 0
11 numbers everytime. the numbers will vary though.
Heres the code:
public String input;
public String values;
info() throws IOException {
//System.out.print("Reading from file.");
StringBuilder text = new StringBuilder();
String NL = System.getProperty("line.separator");
Scanner scanner = new Scanner(new FileInputStream(Loader.selectedFile1));
try {
while (scanner.hasNextLine()){
text.append(scanner.nextLine() + NL);
input = text.toString();
}
}
finally{
scanner.close();
}
System.out.println(java.util.Arrays.toString(
input.split(" ")));
values = java.util.Arrays.toString(input.split(" "));
}
This will output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 0]
Can someone help me conver these into integers and fill them into an array? This is killing me :)
thanks
Theformand