With Java:
I have a byte[]
that represents a file.
How do I write this to a file (ie. C:\myfile.pdf
)
I know it's done with InputStream, but I can't seem to work it out.
With Java:
I have a byte[]
that represents a file.
How do I write this to a file (ie. C:\myfile.pdf
)
I know it's done with InputStream, but I can't seem to work it out.
////////////////////////// 1] File to Byte [] ///////////////////
/////////////////////// 2] Byte [] to File ///////////////////////////
Actually, you'd be writing to a file output...
You can try Cactoos:
More details: http://www.yegor256.com/2017/06/22/object-oriented-input-output-in-cactoos.html
Try an
OutputStream
or more specificallyFileOutputStream
This is a program where we are reading and printing array of bytes offset and length using String Builder and Writing the array of bytes offset length to the new file.
`Enter code here
O/P in console : fghij
O/P in new file :cdefg
Without any libraries:
With Google Guava:
With Apache Commons:
All of these strategies require that you catch an IOException at some point too.