Skip to content Skip to sidebar Skip to footer

Android: Write PNG ByteArray To File

I have read an image file into ByteArray, but how can I write it back. I mean save ByteArray to image file in the file system. PNG format preferred. My code from PNG file to ByteAr

Solution 1:

Just use a FileOutputStream to write your byte array into. Like this:

File file = new File(getFilesDir()+"/file.png");
FileOutputStream fos = new FileOutputStream(file);

//write your byteArray here
fos.write(byteArray);
fos.flush();
fos.close();

Post a Comment for "Android: Write PNG ByteArray To File"