Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package m3uf3path.backup;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- public class CopyFile {
- public static void main(String[] args) {
- InputStream inputStream = null;
- OutputStream outputStream = null;
- try {
- File archivoOriginal = new File("D:\\code\\source\\original.txt");
- File archivoCopia = new File("D:\\code\\destination\\copia.txt");
- inputStream = new FileInputStream(archivoOriginal);
- outputStream = new FileOutputStream(archivoCopia);
- byte[] buffer = new byte[1024];
- int length;
- while ((length = inputStream.read(buffer)) > 0) {
- outputStream.write(buffer, 0, length);
- }
- inputStream.close();
- outputStream.close();
- System.out.println("Archivo copiado.");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement