MCPcopy
hub / github.com/arduino/Arduino / copyFile

Method copyFile

app/src/processing/app/Base.java:2269–2288  ·  view source on GitHub ↗
(File sourceFile,
                              File targetFile)

Source from the content-addressed store, hash-verified

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 /**

Callers 2

handleOpenInternalMethod · 0.95
addFileMethod · 0.95

Calls 3

readMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected