Os dejo un codigo para copiar ficheros de un sitio a otro
Hola a todos, he estado buscando como copiar ficheros en este foro y he visto que habia muxa gente como yo.... asique como he encontrado un codigo que me funciona lo pongo por si le hace falta a alguien.
File fichero =new File("rutadelfichero/fichero");
File direc = new File("rutadondelopegamos/fichero");
InputStream in = new FileInputStream(fichero);
OutputStream out = new FileOutputStream(direc);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
espero que le sirva a alguien de ayuda. un saludo
File fichero =new File("rutadelfichero/fichero");
File direc = new File("rutadondelopegamos/fichero");
InputStream in = new FileInputStream(fichero);
OutputStream out = new FileOutputStream(direc);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
espero que le sirva a alguien de ayuda. un saludo
Si, muy útil. Sobre todo teniendo en cuenta que la Entrada/Salida en JAVA es un poco liosa, debido a que hay un montón de clases.
