Results 1 to 3 of 3
- 04-28-2011, 10:14 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
Help with reading file into array
I am trying to read a file into separate arrays, the program works, but when I try to print the individual arrays it returns something like this: [I@b749757, which is wrong. Each array has 125 integers in it. Any ideas on how to get it to print the correct contents of the arrays?
for (int x = 1; x <= FILESIZE; x++){
String temp = reader.readLine();
if (x > 0 && x <= (FILESIZE/8))
array1[x] = reader.read();
if (x > FILESIZE/8 && x <= 2*(FILESIZE/8))
array2[x-125] = Integer.parseInt(temp);
if (x > 2*FILESIZE/8 && x <= 3*(FILESIZE/8))
array3[x-250] = Integer.parseInt(temp);
if (x > 3*FILESIZE/8 && x <= 4*(FILESIZE/8))
array4[x-375] = Integer.parseInt(temp);
if (x > 4*FILESIZE/8 && x <= 5*(FILESIZE/8))
array5[x-500] = Integer.parseInt(temp);
if (x > 5*FILESIZE/8 && x <= 6*(FILESIZE/8))
array6[x-625] = Integer.parseInt(temp);
if (x > 6*FILESIZE/8 && x <= 7*(FILESIZE/8))
array7[x-750] = Integer.parseInt(temp);
if (x > 7*FILESIZE/8 && x <= 8*(FILESIZE/8))
array8[x-875] = Integer.parseInt(temp);
}// for
-
Your output is correct as it's the toString() result returned by array objects. If you want to print the array contents, you'll have to either iterate through the array with a for loop printing each item within the loop, or else you could call the Arrays utility class's toString method. For instance if your array was named myArray, then ...
Java Code:System.out.println(java.util.Arrays.toString(myArray));
- 04-28-2011, 10:24 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Reading csv file into 2D array - HELP!!!
By mikeg in forum New To JavaReplies: 17Last Post: 04-12-2011, 08:36 AM -
Reading from a text file into an array
By xyknight in forum New To JavaReplies: 16Last Post: 04-10-2011, 11:10 PM -
Help with reading from file into an array
By Trad in forum New To JavaReplies: 3Last Post: 10-22-2010, 12:16 PM -
Reading a txt file and then storing it in a 2d array
By blkshp1990 in forum New To JavaReplies: 2Last Post: 11-05-2009, 12:31 AM -
Reading input file into an array
By littlefire in forum New To JavaReplies: 6Last Post: 10-18-2008, 11:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks