(File sourceFile,
File targetFile)
| 125 | |
| 126 | |
| 127 | static public void copyFile(File sourceFile, |
| 128 | File targetFile) throws IOException { |
| 129 | BufferedInputStream from = |
| 130 | new BufferedInputStream(new FileInputStream(sourceFile)); |
| 131 | BufferedOutputStream to = |
| 132 | new BufferedOutputStream(new FileOutputStream(targetFile)); |
| 133 | byte[] buffer = new byte[16 * 1024]; |
| 134 | int bytesRead; |
| 135 | while ((bytesRead = from.read(buffer)) != -1) { |
| 136 | to.write(buffer, 0, bytesRead); |
| 137 | } |
| 138 | from.close(); |
| 139 | from = null; |
| 140 | |
| 141 | to.flush(); |
| 142 | to.close(); |
| 143 | to = null; |
| 144 | |
| 145 | targetFile.setLastModified(sourceFile.lastModified()); |
| 146 | targetFile.setExecutable(sourceFile.canExecute()); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /** |
no test coverage detected