Part filePart = request.getPart("barcodePhtotoVen");
inputStream = filePart.getInputStream();
How to write this using outputstream to folder/file in my computer drive?
Part filePart = request.getPart("barcodePhtotoVen");
inputStream = filePart.getInputStream();
How to write this using outputstream to folder/file in my computer drive?
Hope following code snippet help you
Update :
OutputStream out = null;
InputStream filecontent = null;
try {
out = new FileOutputStream(new File("destination_file_path"));
filecontent = filePart.getInputStream();
int read = 0;
final byte[] bytes = new byte[1024];
while ((read = filecontent.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
} catch (FileNotFoundException f) {
} finally {
if (out != null) {
out.close();
}
}
Earlier code I tested on mine system, perfectly worked. Please try mine updated code. I just tested on mine system and its working fine too.
Resources : Hope this knowledge sharing help you.
Thanks.
Do not use an InputStream and do not use an OutputStream. Part has a write(String) method which writes the part directly to a file.
I have stored image to inputstream
No you haven't. You haven't stored the image anywhere, let alone to an input stream, which is a contradiction in terms. You need to read from the input stream and write to a disk file.