Solved

reading bytes from a file into an array

Posted on 2003-11-29
5
294 Views
Last Modified: 2012-05-04
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
Comment
Question by:abstractionz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9844344
code looks alright, can you post the code that is using the loaded array?
0
 

Author Comment

by:abstractionz
ID: 9844408
after posting the question i figured out what the problem was.  by accident i assigned the array objects to the same array.
0
 

Author Comment

by:abstractionz
ID: 9844435
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
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 9844452
You need to use RandomAccessFile.
0
 
LVL 92

Expert Comment

by:objects
ID: 9844472
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question