Ignore:
Timestamp:
2014-10-19T01:27:04+02:00 (12 years ago)
Author:
donvip
Message:

[josm_plugins] fix java 7 warnings / global usage of try-with-resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r30737 r30738  
    4747    private static String errorMessage;
    4848
     49    /**
     50     * Constructs a new {@code DownloadSVGTask}.
     51     */
    4952    public DownloadSVGTask(WMSLayer wmsLayer) {
    5053        super(tr("Downloading {0}", wmsLayer.getName()));
     
    194197        wmsInterface.urlConn.setRequestMethod("GET");
    195198        wmsInterface.setCookie();
    196         InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE);
    197199        File file = new File(CadastrePlugin.cacheDir + "boundary.svg");
    198200        String svg = new String();
    199         try {
     201        try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
    200202            if (file.exists())
    201203                file.delete();
    202             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
    203             InputStreamReader isr =new InputStreamReader(is);
    204             BufferedReader br = new BufferedReader(isr);
    205             String line="";
    206             while ( null!=(line=br.readLine())){
    207                 line += "\n";
    208                 bos.write(line.getBytes());
    209                 svg += line;
     204            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
     205                 InputStreamReader isr =new InputStreamReader(is);
     206                 BufferedReader br = new BufferedReader(isr)) {
     207                String line="";
     208                while ( null!=(line=br.readLine())){
     209                    line += "\n";
     210                    bos.write(line.getBytes());
     211                    svg += line;
     212                }
    210213            }
    211             br.close();
    212             bos.close();
    213214        } catch (IOException e) {
    214             e.printStackTrace(System.out);
    215         }
    216         is.close();
     215            Main.error(e);
     216        }
    217217        return svg;
    218218    }
Note: See TracChangeset for help on using the changeset viewer.