0

Let's say I want to read a binary file which contains three of data types char, int and double (However,this binary file can contain any number of these three data types in any order.). And then I want to store three of these data types to char array list, double array list and integer array list. Anyone could be able to help? I really appreciate it.

2
  • What for do you need this? Commented Apr 27, 2013 at 21:39
  • @AndrewLogvinov What difference does it make? There are plenty of binary file formats out there, and they all need reading. Commented Apr 27, 2013 at 22:18

2 Answers 2

2

Your file needs some kind of map on how to read it. There is no magic function that can distinguish between lets say 4 char and 1 int.

You need to open the file, read the map then read the file accordingly

Sign up to request clarification or add additional context in comments.

3 Comments

What exactly do you mean by map?
You need a place in your file that says "3 chars in a row, then 2 ints in a row, then a double, then 2 more chars" and so on
@SHAWNNN Use Channels :D
2

The basic answer is DataInputStream. It has methods to read all the primitive datatypes. When you read which type is of course up to you :-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.