Skip to content

Instantly share code, notes, and snippets.

@oriapp
Created February 18, 2022 16:03
Show Gist options
  • Save oriapp/3f898b4449823e2218da4f82097e7206 to your computer and use it in GitHub Desktop.
Save oriapp/3f898b4449823e2218da4f82097e7206 to your computer and use it in GitHub Desktop.
import java.io.*;
public class fileing {
public static void main(String[] args) {
}
void copyFileBuffer(File src, File dest) throws IOException {
try (var in = new BufferedInputStream(
new FileInputStream(src));
var out = new BufferedOutputStream(
new FileOutputStream(dest))) {
var buffer = new byte[1024];
int lengthRead;
while ((lengthRead = in.read(buffer)) > 0) {
out.write(buffer, 0, lengthRead);
out.flush();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment