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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -