• Post Reply Bookmark Topic Watch Topic
  • New Topic

writing a file from a byte array

 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a cleaner, better, faster, more robust etc. way of doing this ...



It works, but is there a better way?

Thanks,
Joe
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well since you already have all the bytes in a single array, you really don't to use a ByteArrayInputStream to read the bytes into another array. You can just skip that:

I also added the try/finally for robustness - that's pretty much always a good idea whenever something needs to be closed after you use it.
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. In retrospect, now its clear I had introduced unnecessary code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!