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++){
if (x > 0 && x <= (FILESIZE/8))
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

2. 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));

3. Member
Join Date
Apr 2011
Posts
7
Rep Power
0
thats what it was, thanks for the help