logo separator

[mkgmap-dev] Resource leaks

From Gerd Petermann gpetermann_muenchen at hotmail.com on Tue May 6 15:49:07 BST 2014

Hi programmers,

Eclipse complains about a lot places in the source code., e.g.
"Resource leak: 'fmt' is never closed    SyntaxException.java    /mkgmap/src/uk/me/parabola/mkgmap/scan    line 45    Java Problem"

The code looks like this:

    public String getMessage() {
        Formatter fmt = new Formatter();
        fmt.format("Error: ");
        if (fileName != null)
            fmt.format("(%s:%d): ", fileName, lineNumber);

        fmt.format(super.getMessage());
        return fmt.toString();
    }

The message disappears if I change the last line to this:
        String res = fmt.toString();
        fmt.close();
        return res;

Does anybody know if this can really improve something?

Gerd
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20140506/02c590e9/attachment.html>


More information about the mkgmap-dev mailing list