Otro snippet para tener bien a mano. De esta manera podemos copiar archivos binarios o ascii.

String source = "c:/myfile.x";
String destiny = "c:/mycopy.x";
File sourceFile = new File(source);
File destinyFile = new File(destiny);
InputStream in = new FileInputStream(sourceFile);

OutputStream out = new FileOutputStream(destinyFile);

byte[] buf = new byte[2048];
int len;
while ((len = in.read(buf)) > 0) {
	out.write(buf, 0, len);
}
in.close();
out.close();
Categories: java

Rodrigo Asensio

Apasionado por la tecnología

Leave a Reply

Your email address will not be published. Required fields are marked *