(File sourceFile,
File targetFile)
| 2267 | |
| 2268 | |
| 2269 | static public void copyFile(File sourceFile, |
| 2270 | File targetFile) throws IOException { |
| 2271 | InputStream from = null; |
| 2272 | OutputStream to = null; |
| 2273 | try { |
| 2274 | from = new BufferedInputStream(new FileInputStream(sourceFile)); |
| 2275 | to = new BufferedOutputStream(new FileOutputStream(targetFile)); |
| 2276 | byte[] buffer = new byte[16 * 1024]; |
| 2277 | int bytesRead; |
| 2278 | while ((bytesRead = from.read(buffer)) != -1) { |
| 2279 | to.write(buffer, 0, bytesRead); |
| 2280 | } |
| 2281 | to.flush(); |
| 2282 | } finally { |
| 2283 | IOUtils.closeQuietly(from); |
| 2284 | IOUtils.closeQuietly(to); |
| 2285 | } |
| 2286 | |
| 2287 | targetFile.setLastModified(sourceFile.lastModified()); |
| 2288 | } |
| 2289 | |
| 2290 | |
| 2291 | /** |
no test coverage detected