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.
FileUtils.writeByteArrayToFile(new File("pathname"), myByteArray)
Or, if you insist on making work for yourself...
try (FileOutputStream fos = new FileOutputStream("pathname")) {
fos.write(myByteArray);
//fos.close(); There is no more need for this line since you had created the instance of "fos" inside the try. And this will automatically close the OutputStream
}