Changeset 9280 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2016-01-03T16:30:55+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r9168 r9280 5 5 6 6 import java.io.BufferedInputStream; 7 import java.io.BufferedOutputStream;8 7 import java.io.File; 9 8 import java.io.FileInputStream; 10 import java.io.FileOutputStream;11 9 import java.io.IOException; 12 10 import java.io.InputStream; 13 import java.io.OutputStream;14 11 import java.net.HttpURLConnection; 15 12 import java.net.MalformedURLException; 16 13 import java.net.URL; 17 14 import java.nio.charset.StandardCharsets; 15 import java.nio.file.Files; 16 import java.nio.file.StandardCopyOption; 18 17 import java.util.ArrayList; 19 18 import java.util.Arrays; … … 429 428 return localFile; 430 429 } 431 try ( 432 InputStream bis = new BufferedInputStream(con.getContent()); 433 OutputStream fos = new FileOutputStream(destDirFile); 434 OutputStream bos = new BufferedOutputStream(fos) 435 ) { 436 byte[] buffer = new byte[4096]; 437 int length; 438 while ((length = bis.read(buffer)) > -1) { 439 bos.write(buffer, 0, length); 440 } 430 try (InputStream bis = new BufferedInputStream(con.getContent())) { 431 Files.copy(bis, destDirFile.toPath(), StandardCopyOption.REPLACE_EXISTING); 441 432 } 442 433 localFile = new File(destDir, localPath);
Note:
See TracChangeset
for help on using the changeset viewer.