• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

reading bytes from a file into an array

i am trying to read sets of bytes from a file into a 2d array.  my loop looks like this:

for ( int i = 0; i < numOfSets; i++) {
  theSets[i][0] = read in part of Set1;
  theSets[i][1] = read in part of Set1;
                     .
                     .
}

however, once the loop is finished, i only have the last set of bytes and its parts filling the whole array.
0
abstractionz
Asked:
abstractionz
  • 3
  • 2
1 Solution
 
objectsCommented:
code looks alright, can you post the code that is using the loaded array?
0
 
abstractionzAuthor Commented:
after posting the question i figured out what the problem was.  by accident i assigned the array objects to the same array.
0
 
abstractionzAuthor Commented:
perhaps you can help me with another question.  how do i write to a file a certain number of bytes into it.  i know DataInputStream has skipbytes but i don't see anything like that for DataOutputStream.
0
 
objectsCommented:
You need to use RandomAccessFile.
0
 
objectsCommented:
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now