I am trying to convert an image(png,jpg,tiff,gif) to a File on disk.When I view it after storing it on file, I cannot see the file.
Here is some code I have tried based on other forum discussions:
byte[] inFileName = org.apache.commons.io.FileUtils.readFileToByteArray(new File("c:/test1.png"));
InputStream inputStream = new ByteArrayInputStream(inFilename);
..String fileName="test.png";
Writer writer = new FileWriter(fileName);
IOUtils.copy(inputStream, writer,"ISO-8859-1");
This creates a png file I cannot see.
I tried using ImageIO based on some other discussion but can't get it to work.Any help is appreciated.
Image inImage = ImageIO.read(new ByteArrayInputStream(inFilename));
BufferedImage outImage = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
OutputStream os = new FileOutputStream(fileName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
//encoder.encode(inImage);