fileinputstream - Java Resource Leak -


i have code snippet in application , quite sure have closed streams.

but, surprisingly, keep getting: resource acquired @ attached stack trace never released. see java.io.closeable information on avoiding resource leaks. java.lang.throwable: explicit termination method 'close' not called

any pointers useful.

if (fd != null) {     inputstream filestream = new fileinputstream(fd.getfiledescriptor());     bytearrayoutputstream bos = new bytearrayoutputstream();     byte[] buf = new byte[1024];     try {         (int readnum; (readnum = filestream.read(buf)) != -1;) {             bos.write(buf, 0, readnum);         }         content = bos.tobytearray();     } catch (ioexception ex) {         ex.printstacktrace();     } {         try {              if (filestream != null) {                 filestream.close();             }              if (bos != null) {                 bos.close();             }         } catch (ioexception e) {             e.printstacktrace();         }     } } 

try moving instantiation of streams try

inputstream filestream = null; bytearrayoutputstream bos = null; byte[] buf = new byte[1024]; try {    filestream = new fileinputstream(fd.getfiledescriptor());   bos = new bytearrayoutputstream(); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -