Now i believe this is an easy one, Although i have tried quiet a few methods of doing this.. The textfile data that my clients other program generates seperates the collumns all with a different ammount of spacing.
Here is the code i have written to try to split the data into a java 2D array:
FileInputStream fstream = new FileInputStream("AD Converter/temp/program.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; int i = 0; while ((line = br.readLine()) != null){ String[] temp = line.split("\\s+"); data[i][0] = temp[0]; data[i][1] = temp[1]; //data[i][2] = temp[2]; //data[i][3] = temp[3]; //data[i][4] = temp[4]; //data[i][5] = temp[5]; System.out.println(data[i][0]); //System.out.println(data[i][1]); i++; }
Now here is the textfile layout that i am trying to split:
MC Cnj Jup (L) Tr-Na 00:01am 14°Ar3'D 13°Ar49'D Asc Sxt Sun/Sat (E) Tr-Na 00:02am 26°Ge1'D 27°Le1'D Asc Sqr Sat (E) Tr-Na 00:05am 27°Ge05'D 27°Vi45'D Mon Tri Jup/Sat (L) Tr-Na 00:0am 06°Pi47'D 0°Cn47'D
Could somebody give me a heads up?
although i may have just relized that it could be split through tabs instead of spaces.. will try it and post back
EDIT: Nope it is still giving me a null error, Below is the error messages spitting out at me:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at newFile.doMaths(newFile.java:30) at newFile.<init>(newFile.java:13) at calculate.<init>(calculate.java:17) at updateData.<init>(updateData.java:16) at correctData.<init>(correctData.java:25) at correctData.main(correctData.java:211)