Changeset 7033 in josm for trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
- Timestamp:
- 2014-05-01T02:34:43+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r7026 r7033 11 11 import java.io.IOException; 12 12 import java.io.InputStream; 13 import java.io.OutputStream; 13 14 import java.net.HttpURLConnection; 14 15 import java.net.MalformedURLException; … … 184 185 } 185 186 187 @SuppressWarnings("resource") 186 188 private Pair<String, InputStream> findZipEntryImpl(String extension, String namepart) { 187 189 if (file == null) … … 293 295 String localPath = "mirror_" + a; 294 296 destDirFile = new File(destDir, localPath + ".tmp"); 295 BufferedOutputStream bos = null;296 BufferedInputStream bis = null;297 297 try { 298 298 HttpURLConnection con = connectFollowingRedirect(url, httpAccept); 299 bis = new BufferedInputStream(con.getInputStream()); 300 FileOutputStream fos = new FileOutputStream(destDirFile); 301 bos = new BufferedOutputStream(fos); 302 byte[] buffer = new byte[4096]; 303 int length; 304 while ((length = bis.read(buffer)) > -1) { 305 bos.write(buffer, 0, length); 306 } 307 Utils.close(bos); 308 bos = null; 309 /* close fos as well to be sure! */ 310 Utils.close(fos); 311 fos = null; 299 try ( 300 InputStream bis = new BufferedInputStream(con.getInputStream()); 301 OutputStream fos = new FileOutputStream(destDirFile); 302 OutputStream bos = new BufferedOutputStream(fos) 303 ) { 304 byte[] buffer = new byte[4096]; 305 int length; 306 while ((length = bis.read(buffer)) > -1) { 307 bos.write(buffer, 0, length); 308 } 309 } 312 310 localFile = new File(destDir, localPath); 313 311 if(Main.platform.rename(destDirFile, localFile)) { … … 325 323 throw e; 326 324 } 327 } finally {328 Utils.close(bis);329 Utils.close(bos);330 325 } 331 326
Note:
See TracChangeset
for help on using the changeset viewer.
