Hi guys, I’ve been getting this errors using upload component.
java.io.IOException: Stream Closed
at java.io.FileInputStream.readBytes(Native Method) ~[na:1.8.0_131]
at java.io.FileInputStream.read(FileInputStream.java:233) ~[na:1.8.0_131]
at com.main.webex.MembersAccount.convertStreamToString(MembersAccount.java:422) ~[classes/:na]
.
.
upload.addSucceededListener(event -> {
Notification.show(event.getFileName()+" "+event.getMIMEType());
try {
System.out.println("result: "+convertStreamToString(fileBuffer.getInputStream()));
} catch (IOException ex) {
Logger.getLogger(MembersAccount.class.getName()).log(Level.SEVERE, null, ex);
}
});
String convertStreamToString(InputStream is) throws IOException{
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024]
;
int length;
while ((length = is.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
// StandardCharsets.UTF_8.name() > JDK 7
return result.toString("UTF-8");
}
After getting tired of looking for a solution, I have found this ticket https://github.com/vaadin/vaadin-upload-flow/issues/105
Has anyone encountered the same problem? was the ticket already been solved?