(File sourceFile,
File targetFile)
| 162 | |
| 163 | |
| 164 | static public void copyFile(File sourceFile, |
| 165 | File targetFile) throws IOException { |
| 166 | BufferedInputStream from = |
| 167 | new BufferedInputStream(new FileInputStream(sourceFile)); |
| 168 | BufferedOutputStream to = |
| 169 | new BufferedOutputStream(new FileOutputStream(targetFile)); |
| 170 | byte[] buffer = new byte[16 * 1024]; |
| 171 | int bytesRead; |
| 172 | while ((bytesRead = from.read(buffer)) != -1) { |
| 173 | to.write(buffer, 0, bytesRead); |
| 174 | } |
| 175 | from.close(); |
| 176 | |
| 177 | to.flush(); |
| 178 | to.close(); |
| 179 | |
| 180 | //noinspection ResultOfMethodCallIgnored |
| 181 | targetFile.setLastModified(sourceFile.lastModified()); |
| 182 | //noinspection ResultOfMethodCallIgnored |
| 183 | targetFile.setExecutable(sourceFile.canExecute()); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | /** |
no test coverage detected