views:

184

answers:

2

Hello i want to Saving an BufferedImage to raw bytes i do this for the moment

InputStream in = new ByteArrayInputStream(fileData);
BufferedImage image = javax.imageio.ImageIO.read(in);
BufferedImage imageModifier = ResizeImage.resize(image, 10, 10);

but know i want to save my file so i don(t know how to convert for do this

FileOutputStream fileOutStream = new FileOutputStream(fileToCreate);
fileOutStream.write(fileData);

Thanks

+1  A: 

Your code is confusing. Why do you have a variable called fileData and why are you using FileOutputStream when you are trying to write to raw bytes? (Which I assume you mean byte array?)

If what you really want is to save a BufferedImage to file use javax.imageio.ImageIO

Pyrolistical
byte[] fileData = newfile.getFileData();when i've got my fileData i convert to BufferedImage for resize my image and when i rezie my image i write into a folder with the FileOutputStream
Nander
Ok then read up on ImageIO, its what you need.Also you don't need to use newFile.getFileData(). Just do `InputStream in = new FileInputStream(new File(<path to file>));`
Pyrolistical
+1  A: 

From the Java 2D trail: Writing/Saving an Image

Devon_C_Miller