Sorry if my code seems bad, I’m not that experienced at programming. I need to transfer text from a .txt in the format of: Date-Name-Address-etc..
I’m reading in the file, then splitting the string with String.split(“-“). I’m having trouble with the loops.
try{
File file = new File("testwrite.txt");
Scanner scan = new Scanner(file);
String[] test = scan.nextLine().split("-");
while(r<100){
while(c<6){
data[r][c] = test[c];
test = scan.nextLine().split("-");
c++;
}
r++;
c = 0 ;
}
System.out.println(data[1][5]);
}catch(Exception e){
System.out.println("Error: " + e.getMessage());
}
Two dimensional array is just “array of arrays”, so you can directly use
splitresult to store the data of one line.