Changeset 16816 in josm
- Timestamp:
- 2020-08-02T15:30:15+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
r16815 r16816 9 9 import java.io.FileNotFoundException; 10 10 import java.io.IOException; 11 import java. nio.file.Files;11 import java.io.InputStream; 12 12 import java.nio.file.NoSuchFileException; 13 13 import java.nio.file.Paths; … … 36 36 import org.openstreetmap.josm.data.projection.Projections; 37 37 import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData; 38 import org.openstreetmap.josm.io.Compression; 38 39 import org.openstreetmap.josm.io.IllegalDataException; 39 40 import org.openstreetmap.josm.io.OsmReader; … … 572 573 throw new IllegalArgumentException(tr("Missing argument - input data file ({0})", "--input|-i")); 573 574 } 574 try {575 return OsmReader.parseDataSet( Files.newInputStream(Paths.get(argInput)), null);575 try (InputStream inputStream = Compression.getUncompressedFileInputStream(Paths.get(argInput))) { 576 return OsmReader.parseDataSet(inputStream, null); 576 577 } catch (IllegalDataException e) { 577 578 throw new IllegalDataException(tr("In .osm data file ''{0}'' - ", argInput) + e.getMessage(), e); -
trunk/src/org/openstreetmap/josm/io/Compression.java
r15588 r16816 9 9 import java.nio.file.Files; 10 10 import java.nio.file.InvalidPathException; 11 import java.nio.file.Path; 11 12 import java.util.zip.GZIPInputStream; 12 13 import java.util.zip.GZIPOutputStream; … … 177 178 public static InputStream getUncompressedFileInputStream(File file) throws IOException { 178 179 try { 179 InputStream in = Files.newInputStream(file.toPath()); // NOPMD 180 try { 181 return byExtension(file.getName()).getUncompressedInputStream(in); 182 } catch (IOException e) { 183 Utils.close(in); 184 throw e; 185 } 180 return getUncompressedFileInputStream(file.toPath()); // NOPMD 186 181 } catch (InvalidPathException e) { 187 182 throw new IOException(e); 183 } 184 } 185 186 /** 187 * Returns an un-compressing {@link InputStream} for the {@link Path} {@code path}. 188 * @param path path 189 * @return un-compressing input stream 190 * @throws IOException if any I/O error occurs 191 * @since 16816 192 */ 193 public static InputStream getUncompressedFileInputStream(Path path) throws IOException { 194 InputStream in = Files.newInputStream(path); // NOPMD 195 try { 196 return byExtension(path.getFileName().toString()).getUncompressedInputStream(in); 197 } catch (IOException e) { 198 Utils.close(in); 199 throw e; 188 200 } 189 201 } … … 221 233 */ 222 234 public static OutputStream getCompressedFileOutputStream(File file) throws IOException { 223 OutputStream out = Files.newOutputStream(file.toPath()); // NOPMD 235 return getCompressedFileOutputStream(file.toPath()); // NOPMD 236 } 237 238 /** 239 * Returns a compressing {@link OutputStream} for the {@link Path} {@code path}. 240 * @param path path 241 * @return compressing output stream 242 * 243 * @throws IOException if any I/O error occurs 244 * @throws InvalidPathException if a Path object cannot be constructed from the abstract path 245 * @since 16816 246 */ 247 public static OutputStream getCompressedFileOutputStream(Path path) throws IOException { 248 OutputStream out = Files.newOutputStream(path); // NOPMD 224 249 try { 225 return byExtension( file.getName()).getCompressedOutputStream(out);250 return byExtension(path.getFileName().toString()).getCompressedOutputStream(out); 226 251 } catch (IOException e) { 227 252 Utils.close(out);
Note:
See TracChangeset
for help on using the changeset viewer.