Copiar archivos en java
importar java.io.FileInputStream;
importar java.io.FileOutputStream;
importar java.nio.channels.FileChannel;
clase pública TestTransfer { p>
p>
public static void main(String[] args) lanza una excepción {
FileInputStream fis = new FileInputStream("c:\abc.txt");
FileOutputStream fos = new FileOutputStream("c:\\123.txt");
FileChannel fc1 = fis.getChannel();
FileChannel fc2 = fos.getChannel( );
fc2.transferFrom(fc1, 0, fc1.size());
fc1.close();
fc2.close();
fis.close();
}
}
}
Esta es la forma más eficiente y método más rápido. Úselo con precaución.