Changeset 9280 in josm for trunk/src/org/openstreetmap/josm/plugins/Plugin.java
- Timestamp:
- 2016-01-03T16:30:55+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r9231 r9280 4 4 import java.io.File; 5 5 import java.io.FileNotFoundException; 6 import java.io.FileOutputStream;7 6 import java.io.IOException; 8 7 import java.io.InputStream; 9 8 import java.net.URL; 10 9 import java.net.URLClassLoader; 10 import java.nio.file.Files; 11 import java.nio.file.StandardCopyOption; 11 12 import java.security.AccessController; 12 13 import java.security.PrivilegedAction; … … 119 120 pluginDir.mkdirs(); 120 121 } 121 try ( 122 FileOutputStream out = new FileOutputStream(new File(pluginDirName, to)); 123 InputStream in = getClass().getResourceAsStream(from) 124 ) { 122 try (InputStream in = getClass().getResourceAsStream(from)) { 125 123 if (in == null) { 126 124 throw new IOException("Resource not found: "+from); 127 125 } 128 byte[] buffer = new byte[8192]; 129 for (int len = in.read(buffer); len > 0; len = in.read(buffer)) { 130 out.write(buffer, 0, len); 131 } 126 Files.copy(in, new File(pluginDirName, to).toPath(), StandardCopyOption.REPLACE_EXISTING); 132 127 } 133 128 }
Note:
See TracChangeset
for help on using the changeset viewer.