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

Location:
applications/editors/josm/plugins/poly/src/poly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/poly/src/poly/PolyExporter.java

    r30737 r30738  
    2525/**
    2626 * Writes poly files.
    27  * 
     27 *
    2828 * @author zverik
    2929 */
     
    3737    public void exportData( File file, Layer layer ) throws IOException {
    3838        if( layer instanceof OsmDataLayer ) {
    39             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
    40             try {
     39            try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"))) {
    4140                DataSet ds = ((OsmDataLayer)layer).data;
    4241                Map<Way, Boolean> ways = new TreeMap<>();
     
    7170                writer.write("END");
    7271                writer.newLine();
    73             } finally {
    74                 writer.close();
    7572            }
    7673        }
  • applications/editors/josm/plugins/poly/src/poly/PolyImporter.java

    r30737 r30738  
    11package poly;
     2
     3import static org.openstreetmap.josm.tools.I18n.tr;
    24
    35import java.io.BufferedReader;
     
    79import java.util.ArrayList;
    810import java.util.List;
     11
    912import javax.swing.JOptionPane;
     13
    1014import org.openstreetmap.josm.Main;
    1115import org.openstreetmap.josm.data.coor.LatLon;
    12 
    13 import static org.openstreetmap.josm.tools.I18n.tr;
    1416import org.openstreetmap.josm.data.osm.DataSet;
    1517import org.openstreetmap.josm.data.osm.Node;
     
    1921import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2022import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     23import org.openstreetmap.josm.io.CachedFile;
    2124import org.openstreetmap.josm.io.IllegalDataException;
    22 import org.openstreetmap.josm.io.CachedFile;
    2325import org.openstreetmap.josm.io.OsmImporter;
    2426import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    4446            progressMonitor = NullProgressMonitor.INSTANCE;
    4547        CheckParameterUtil.ensureParameterNotNull(in, "in");
    46         BufferedReader reader = null;
    47 
    48         try {
     48
     49        try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF8"))) {
    4950            progressMonitor.beginTask(tr("Reading polygon filter file..."), 2);
    5051            progressMonitor.indeterminateSubTask(tr("Reading polygon filter file..."));
    51             reader = new BufferedReader(new InputStreamReader(in, "UTF8"));
    5252            List<Area> areas = loadPolygon(reader);
    5353            progressMonitor.worked(1);
    54            
     54
    5555            progressMonitor.indeterminateSubTask(tr("Preparing data set..."));
    5656            DataSet ds = constructDataSet(areas);
     
    6060            throw new IllegalDataException(tr("Error reading poly file: {0}", e.getMessage()), e);
    6161        } finally {
    62             try {
    63                 if( reader != null )
    64                     reader.close();
    65             } catch( IOException e ) { }
    6662            progressMonitor.finishTask();
    6763        }
    6864    }
    69    
     65
    7066    private List<Area> loadPolygon( BufferedReader reader ) throws IllegalDataException, IOException {
    7167        String name = reader.readLine();
     
    145141        DataSet ds = new DataSet();
    146142        ds.setUploadDiscouraged(true);
    147        
     143
    148144        boolean foundInner = false;
    149145        for( Area area : areas ) {
Note: See TracChangeset for help on using the changeset viewer.