Changeset 30738 in osm for applications/editors/josm/plugins/poly/src
- Timestamp:
- 2014-10-19T01:27:04+02:00 (10 years ago)
- 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 25 25 /** 26 26 * Writes poly files. 27 * 27 * 28 28 * @author zverik 29 29 */ … … 37 37 public void exportData( File file, Layer layer ) throws IOException { 38 38 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"))) { 41 40 DataSet ds = ((OsmDataLayer)layer).data; 42 41 Map<Way, Boolean> ways = new TreeMap<>(); … … 71 70 writer.write("END"); 72 71 writer.newLine(); 73 } finally {74 writer.close();75 72 } 76 73 } -
applications/editors/josm/plugins/poly/src/poly/PolyImporter.java
r30737 r30738 1 1 package poly; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import java.io.BufferedReader; … … 7 9 import java.util.ArrayList; 8 10 import java.util.List; 11 9 12 import javax.swing.JOptionPane; 13 10 14 import org.openstreetmap.josm.Main; 11 15 import org.openstreetmap.josm.data.coor.LatLon; 12 13 import static org.openstreetmap.josm.tools.I18n.tr;14 16 import org.openstreetmap.josm.data.osm.DataSet; 15 17 import org.openstreetmap.josm.data.osm.Node; … … 19 21 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 20 22 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 23 import org.openstreetmap.josm.io.CachedFile; 21 24 import org.openstreetmap.josm.io.IllegalDataException; 22 import org.openstreetmap.josm.io.CachedFile;23 25 import org.openstreetmap.josm.io.OsmImporter; 24 26 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 44 46 progressMonitor = NullProgressMonitor.INSTANCE; 45 47 CheckParameterUtil.ensureParameterNotNull(in, "in"); 46 BufferedReader reader = null; 47 48 try { 48 49 try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF8"))) { 49 50 progressMonitor.beginTask(tr("Reading polygon filter file..."), 2); 50 51 progressMonitor.indeterminateSubTask(tr("Reading polygon filter file...")); 51 reader = new BufferedReader(new InputStreamReader(in, "UTF8"));52 52 List<Area> areas = loadPolygon(reader); 53 53 progressMonitor.worked(1); 54 54 55 55 progressMonitor.indeterminateSubTask(tr("Preparing data set...")); 56 56 DataSet ds = constructDataSet(areas); … … 60 60 throw new IllegalDataException(tr("Error reading poly file: {0}", e.getMessage()), e); 61 61 } finally { 62 try {63 if( reader != null )64 reader.close();65 } catch( IOException e ) { }66 62 progressMonitor.finishTask(); 67 63 } 68 64 } 69 65 70 66 private List<Area> loadPolygon( BufferedReader reader ) throws IllegalDataException, IOException { 71 67 String name = reader.readLine(); … … 145 141 DataSet ds = new DataSet(); 146 142 ds.setUploadDiscouraged(true); 147 143 148 144 boolean foundInner = false; 149 145 for( Area area : areas ) {
Note:
See TracChangeset
for help on using the changeset viewer.