Changeset 30436 in osm for applications/editors/josm/plugins/openstreetbugs/src/org
- Timestamp:
- 2014-05-09T05:21:14+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/api/util/HttpUtils.java
r29736 r30436 42 42 int length = -1; 43 43 byte[] b = new byte[1024]; 44 InputStream in = Utils.openURL(new URL(url)); 45 while( (length = in.read(b)) > 0 ) { 46 bos.write(b, 0, length); 44 try (InputStream in = Utils.openURL(new URL(url))) { 45 while( (length = in.read(b)) > 0 ) { 46 bos.write(b, 0, length); 47 } 47 48 } 48 Utils.close(in);49 49 50 50 return new String(bos.toByteArray(), charset); … … 66 66 67 67 //send the post 68 OutputStream os = con.getOutputStream(); 69 os.write(content.getBytes("UTF-8")); 70 os.flush(); 68 try (OutputStream os = con.getOutputStream()) { 69 os.write(content.getBytes("UTF-8")); 70 os.flush(); 71 } 71 72 72 73 // read the response … … 74 75 int length = -1; 75 76 byte[] b = new byte[1024]; 76 InputStream in = con.getInputStream(); 77 while( (length = in.read(b)) > 0 ) { 78 bos.write(b, 0, length); 77 try (InputStream in = con.getInputStream()) { 78 while( (length = in.read(b)) > 0 ) { 79 bos.write(b, 0, length); 80 } 79 81 } 80 Utils.close(in);81 Utils.close(os);82 82 83 83 return new String(bos.toByteArray(), responseCharset);
Note:
See TracChangeset
for help on using the changeset viewer.
