Changeset 9280 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2016-01-03T16:30:55+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r9078 r9280 16 16 import java.awt.event.MouseEvent; 17 17 import java.io.BufferedInputStream; 18 import java.io.BufferedOutputStream;19 18 import java.io.BufferedReader; 20 19 import java.io.File; 21 import java.io.FileOutputStream;22 20 import java.io.IOException; 23 21 import java.io.InputStream; 24 22 import java.io.InputStreamReader; 25 import java.io.OutputStream;26 23 import java.nio.charset.StandardCharsets; 24 import java.nio.file.Files; 25 import java.nio.file.StandardCopyOption; 27 26 import java.util.ArrayList; 28 27 import java.util.Arrays; … … 510 509 try { 511 510 InputStream in = s.getSourceInputStream(); 512 try ( 513 InputStream bis = new BufferedInputStream(in); 514 OutputStream bos = new BufferedOutputStream(new FileOutputStream(file)) 515 ) { 516 byte[] buffer = new byte[4096]; 517 int length; 518 while ((length = bis.read(buffer)) > -1 && !canceled) { 519 bos.write(buffer, 0, length); 520 } 511 try (InputStream bis = new BufferedInputStream(in)) { 512 Files.copy(bis, file.toPath(), StandardCopyOption.REPLACE_EXISTING); 521 513 } finally { 522 514 s.closeSourceInputStream(in); 523 515 } 524 516 } catch (IOException e) { 517 Main.warn(e); 525 518 error = true; 526 519 } -
trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java
r9171 r9280 5 5 6 6 import java.awt.Component; 7 import java.io.BufferedOutputStream;8 7 import java.io.File; 9 8 import java.io.FileOutputStream; … … 14 13 import java.net.URL; 15 14 import java.nio.charset.StandardCharsets; 15 import java.nio.file.Files; 16 import java.nio.file.StandardCopyOption; 16 17 import java.util.Enumeration; 17 18 import java.util.zip.ZipEntry; … … 182 183 if (ze.isDirectory()) { 183 184 newFile.mkdirs(); 184 } else try ( 185 InputStream is = zf.getInputStream(ze); 186 OutputStream os = new BufferedOutputStream(new FileOutputStream(newFile)) 187 ) { 188 byte[] buffer = new byte[8192]; 189 int read; 190 while ((read = is.read(buffer)) != -1) { 191 os.write(buffer, 0, read); 192 } 185 } else try (InputStream is = zf.getInputStream(ze)) { 186 Files.copy(is, newFile.toPath(), StandardCopyOption.REPLACE_EXISTING); 193 187 } 194 188 }
Note:
See TracChangeset
for help on using the changeset viewer.