Ignore:
Timestamp:
2014-10-19T01:27:04+02:00 (10 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/DownloadSVGBuilding.java

    r30737 r30738  
    4343    private static String errorMessage;
    4444
    45 
     45    /**
     46     * Constructs a new {@code DownloadSVGBuilding}.
     47     */
    4648    public DownloadSVGBuilding(WMSLayer wmsLayer) {
    4749        super(tr("Downloading {0}", wmsLayer.getName()));
     
    240242        wmsInterface.urlConn.setRequestMethod("GET");
    241243        wmsInterface.setCookie();
    242         InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE);
    243244        File file = new File(CadastrePlugin.cacheDir + "building.svg");
    244245        String svg = new String();
    245         try {
     246        try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
    246247            if (file.exists())
    247248                file.delete();
    248             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
    249             InputStreamReader isr =new InputStreamReader(is);
    250             BufferedReader br = new BufferedReader(isr);
    251             String line="";
    252             while ( null!=(line=br.readLine())){
    253                 line += "\n";
    254                 bos.write(line.getBytes());
    255                 svg += line;
    256             }
    257             br.close();
    258             bos.close();
     249            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
     250                 InputStreamReader isr = new InputStreamReader(is);
     251                 BufferedReader br = new BufferedReader(isr)) {
     252                String line="";
     253                while ( null!=(line=br.readLine())){
     254                    line += "\n";
     255                    bos.write(line.getBytes());
     256                    svg += line;
     257                }
     258            }
    259259        } catch (IOException e) {
    260             e.printStackTrace(System.out);
    261         }
    262         is.close();
     260            Main.error(e);
     261        }
    263262        return svg;
    264263    }
Note: See TracChangeset for help on using the changeset viewer.