dcsimg
LinkedIn
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Convert an InputStream to a Byte Array

How to use Apache Commons IOUtils to convert an InputStream to a byte array.


advertisement

How to use Apache Commons IOUtils to convert an InputStream to a byte array.

Using Apache Commons IOUtils:

InputStream is = ...;
byte[] bytes = IOUtils.toByteArray(is);

Or, using Java 9:

InputStream is = ...;
byte[] bytes = is.readAllBytes();


   
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date