프로그래밍/Java, Android

(Java) FileInputStream, FileOutputStream을 이용한 File Copy 예제

길가다주운노트 2016. 7. 10. 18:53


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.io.*;
 
public class FileCopy {
 
    public static void main(String[] args) throws IOException {
        File input = new File("/Users/ghdrl95/Documents/input.txt");
        File output = new File("/Users/ghdrl95/Documents/output.txt");
        
        FileInputStream in = new FileInputStream(input);
        FileOutputStream out = new FileOutputStream(output);
        
        int cTemp;
        
        while((cTemp = in.read()) != -1){
            out.write(cTemp);
        }
    }
 
}
 
 
 
cs


FileCopy.zip