File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Best approch to read files as Byte Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Best approch to read files as Byte " Watch "Best approch to read files as Byte " New topic

Best approch to read files as Byte

Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
In our application we use 3rd party checksum digest lib that requited to give source file as a byte array or as a ByteBuffer. Source files can be very to 1Mb to ~1GB . Here what is the most efficient approach to read those files in to byte array or ByteBuffer ?

Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Rob Spoor

Joined: Oct 27, 2005
Posts: 20050

Are you sure the lib requires the entire file to be passed into one single byte[] or ByteBuffer? Is it not something like MessageDigest that allows you to update the checksum with chunks at a time? For instance:

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Best approch to read files as Byte
It's not a secret anymore!