I am uploading an image from c:\illuxplain on an android device. I have successfully uploaded the image but when I open it, it does not display.
Image size is non-zero in storage space and it displays extension .png. Why isn't the picture displaying? Is this right way to write file to storage space?
This is my servlet code
for (Part part : request.getParts()) {
String fileName = extractFileName(part);
File file = new File(fileSaveDir, fileName);
InputStream input = part.getInputStream();
byte[] buffer = new byte[1024];
int len = input.read();
FileOutputStream out = new FileOutputStream(file);
while (len!=-1) {
out.write(buffer,0,len);
len = input.read(buffer);
}
out.close();
input.close();
}
