Community
Participate
Working Groups
Here's a simple, correct block of code to un-gzip a file in Java. Eclipse 3.2M5a flags the `while (...)` line with a warning indicating that `is` may be null. It's not hard to imagine why a try block confuses Eclipse, but it's clearly never null. The compiler should analyze method calls in the try part of a try/catch just like any normal block with respect to potentially null targets. static void run(File srcFile, File outFile) throws FileNotFoundException, IOException { int bytesRead; final byte[] buffer = new byte[BUFFER_SIZE]; InputStream is = null; OutputStream os = null; try { is = new GZIPInputStream(new FileInputStream(srcFile)); os = new FileOutputStream(outFile); while ((bytesRead = is.read(buffer)) > -1) { os.write(buffer, 0, bytesRead); } } finally { if (os != null) { os.close(); } if (is != null) { is.close(); } } }
*** This bug has been marked as a duplicate of 128962 ***