The code is taken as an example from the off site of Vaadin:

class ImageUploader implements Receiver, SucceededListener { public File file; public OutputStream receiveUpload(String filename, String mimeType) { // Create and return a file output stream ... } public void uploadSucceeded(SucceededEvent event) { // Show the uploaded file in the image viewer image.setSource(new FileResource(file)); } 

};

The receiveUpload () function returns a stream of type OutputStream , do you need to close this stream? And How? After all, there is no explicit flow instance.

  • Shouldn't you implement this method? I assume that it is not necessary to close, as this thread is used by the client of this class. As I see the use: you are given information about the requested file, you want to get the output stream (from the actual file, database, socket, etc.) and return it. The client does not know where the file is taken from. - ezhov_da
  • As I understand it, the file is transmitted through this stream and, if the download was successful, the uploadSucceeded function is called where it is already possible to work with this file. at the moment I close the stream just in this function manually, but is it worth it? - Azat

0