Changeset 9171 in josm for trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java
- Timestamp:
- 2015-12-26T23:42:00+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java
r9059 r9171 11 11 import java.io.InputStream; 12 12 import java.io.OutputStream; 13 import java.net.HttpURLConnection;14 13 import java.net.MalformedURLException; 15 14 import java.net.URL; … … 22 21 import org.openstreetmap.josm.gui.PleaseWaitDialog; 23 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 import org.openstreetmap.josm.tools. Utils;23 import org.openstreetmap.josm.tools.HttpClient; 25 24 import org.xml.sax.SAXException; 26 25 … … 68 67 69 68 private boolean canceled; 70 private Http URLConnectiondownloadConnection;69 private HttpClient.Response downloadConnection; 71 70 72 71 private synchronized void closeConnectionIfNeeded() { … … 100 99 101 100 URL url = new URL(address); 102 intsize;101 long size; 103 102 synchronized (this) { 104 downloadConnection = Utils.openHttpConnection(url); 105 downloadConnection.setRequestProperty("Cache-Control", "no-cache"); 106 downloadConnection.connect(); 103 downloadConnection = HttpClient.create(url).useCache(false).connect(); 107 104 size = downloadConnection.getContentLength(); 108 105 } … … 112 109 113 110 try ( 114 InputStream in = downloadConnection.get InputStream();111 InputStream in = downloadConnection.getContent(); 115 112 OutputStream out = new FileOutputStream(file) 116 113 ) { 117 114 byte[] buffer = new byte[32768]; 118 115 int count = 0; 119 intp1 = 0, p2 = 0;116 long p1 = 0, p2 = 0; 120 117 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) { 121 118 out.write(buffer, 0, read); … … 124 121 p2 = 100 * count / size; 125 122 if (p2 != p1) { 126 progressMonitor.setTicks( p2);123 progressMonitor.setTicks((int) p2); 127 124 p1 = p2; 128 125 }
Note:
See TracChangeset
for help on using the changeset viewer.