Hi,
I also encountered the same error in mashup components. But, I used the
commons-io for that. i.e.
org.apache.commons.io.IOUtils.closeQuietly(fileWriter);
where try-catch within the following final block has been wrapped within
IOUtils class. I decided to use above method as it gives us a more readable
code. I guess it is all right to use commons-io??
regards,
Ruchira
> public void archiveFile(String from, String to) throws IOException {
> ZipOutputStream out = null;
> FileInputStream in = new FileInputStream(from);
> try {
> out = new ZipOutputStream(new FileOutputStream(to));
> byte[] buffer = new byte[40960];
> int bytesRead;
> while ((bytesRead = in.read(buffer)) != -1) {
> out.write(buffer, 0, bytesRead);
> }
> } finally {
> try {
> in.close();
> } catch (IOException e) {
> log.warn("Unable to close the InputStream " +
> e.getMessage(), e);
> }
>
> try {
> if (out != null) {
> out.close();
> }
> } catch (IOException e) {
> log.warn("Unable to close the OutputStream " +
> e.getMessage(), e);
> }
> }
> }
>
> IMV, we need to close streams in the above manner, otherwise output stream
> won't get closed, if an error occurs while closing the input stream.
>
> Thanks
> Sameera
>
_______________________________________________
Carbon-dev mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev