package ch05_copy;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class BinaryCopy {
	
	public static void main(String[] args) throws IOException {
		
		// 원래 경로
		File org = new File("/Users/simpangyo/FinTech_SPG/IOjava/sentence.txt");
		// 카피할 경로
		File duplicate = new File("/Users/simpangyo/FinTech_SPG/IOjava/copy.txt");
		
		FileInputStream fis = null;
		FileOutputStream fos = null;
		
		try {
			fis = new FileInputStream(org);
			fos = new FileOutputStream(duplicate);
			
			int data = 0;
			while((data = fis.read()) != -1) {
				fos.write((byte)data);
			}
			System.out.println(duplicate.getPath() + " 복사 완료 ");

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				
				fis.close();
				fos.close();
				
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		
		
		// 데이터 전송 통로 생성
		
		
	}
}