Changeset 5874 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2013-04-16T19:57:43+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r5836 r5874 15 15 import org.openstreetmap.josm.gui.download.DownloadSelection; 16 16 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 17 import org.openstreetmap.josm.tools.Utils; 17 18 18 19 /** … … 110 111 pluginDir.mkdirs(); 111 112 } 112 FileOutputStream out = new FileOutputStream(new File(pluginDirName, to)); 113 InputStream in = getClass().getResourceAsStream(from); 114 byte[] buffer = new byte[8192]; 115 for(int len = in.read(buffer); len > 0; len = in.read(buffer)) { 116 out.write(buffer, 0, len); 113 FileOutputStream out = null; 114 InputStream in = null; 115 try { 116 out = new FileOutputStream(new File(pluginDirName, to)); 117 in = getClass().getResourceAsStream(from); 118 byte[] buffer = new byte[8192]; 119 for(int len = in.read(buffer); len > 0; len = in.read(buffer)) { 120 out.write(buffer, 0, len); 121 } 122 } finally { 123 Utils.close(in); 124 Utils.close(out); 117 125 } 118 in.close();119 out.close();120 126 } 121 127 -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r5836 r5874 129 129 out.write(buffer, 0, read); 130 130 } 131 out.close();132 in.close();133 131 } catch(MalformedURLException e) { 134 132 String msg = tr("Warning: Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", pi.name, pi.downloadlink); -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r5836 r5874 29 29 import org.openstreetmap.josm.tools.ImageProvider; 30 30 import org.openstreetmap.josm.tools.LanguageInfo; 31 import org.openstreetmap.josm.tools.Utils; 31 32 32 33 /** … … 100 101 throw new PluginException(name, e); 101 102 } finally { 102 if (jar != null) { 103 try { 104 jar.close(); 105 } catch(IOException e) { /* ignore */ } 106 } 107 if (fis != null) { 108 try { 109 fis.close(); 110 } catch(IOException e) { /* ignore */ } 111 } 103 Utils.close(jar); 104 Utils.close(fis); 112 105 } 113 106 } -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r5836 r5874 218 218 out.write(buffer, 0, read); 219 219 } 220 out.close();221 in.close();222 220 } catch(MalformedURLException e) { 223 221 if (canceled) return; … … 229 227 return; 230 228 } finally { 229 Utils.close(out); 231 230 synchronized(this) { 232 231 if (connection != null) { … … 274 273 if (writer != null) { 275 274 writer.flush(); 276 writer.close();275 Utils.close(writer); 277 276 } 278 277 }
Note: See TracChangeset
for help on using the changeset viewer.