1

I have some binary files which are written by a Java application in the following way:

DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(complete_path_to_file)));

dos.writeInt(aInteger);
dos.writeLong(aLong);
dos.writeFloat(aFloat);

dos.close();

Now, I'd like to read this kind files in a Scala framework but I really don't have any ideas about how to do that.

Could you help me?

3
  • 1
    Why don't you read them in exactly the same way you will do in java? (with DataInputStream and such stuff?) Commented May 23, 2013 at 14:25
  • Yes I could, but I was wondering whether it exists a Scala-idiomatic way to do that Commented May 23, 2013 at 14:27
  • 1
    stackoverflow.com/questions/2667714/… Commented May 23, 2013 at 14:28

1 Answer 1

3

Reading it using the same classes and methods you'd use in Java is probably going to be the most error-free, as you have a direct correspondence between read and write.

You can also use Scala I/O, which is the best library for file I/O for Scala -- and a possible addition to the standard library in the future.

Then there's sbinary, where less concern is given to I/O itself, and more concern is given to describing the binary record.

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

1 Comment

Scala I/O had no commits for 3 years...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.