Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert a file content to a byte array.

680524May 5 2011 — edited May 6 2011
Dear friends,

I have a file and I want to encode the content using org.apache.axis.encoding.Base64.encode(byte[] data, int off, int len, java.io.Writer writer) .

So I need to convert the content to byte array first. The idea comes to me first is to use the FileInputStream to read the content to the byte array. But is is a little complex since I need to think if the file is too big to read once, I need to use buffer and loop statement to handle it finally so that all the content can be read into a byte array.

My question is is there some APIs available to do that more easily?

Thanks,
Ricky
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2011
Added on May 5 2011
4 comments
772 views