Skip to content

Instantly share code, notes, and snippets.

@alxfv
Created August 2, 2012 07:00
Show Gist options
  • Save alxfv/3234644 to your computer and use it in GitHub Desktop.
Save alxfv/3234644 to your computer and use it in GitHub Desktop.
Copy file using OutputStream
File srcFile = new File("/var/www/afishapoisk/public/uploads/images/events/big/new.jpg");
File dstfile = new File("/var/www/afishapoisk/public/uploads/images/events/big/super.jpg");
try {
FileOutputStream dstFos = new FileOutputStream(dstfile);
FileInputStream srcFos = new FileInputStream(srcFile);
byte[] buffer = new byte[256];
int bytesRead;
do {
bytesRead = srcFos.read(buffer, 0, 256);
dstFos.write(buffer, 0, bytesRead);
} while (bytesRead > 0);
dstFos.close();
} catch (Exception e) {
Logger.info(e.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment