적당한 중간 크기로 파일을 받아야 성능이 향상됨
public class ByteIOExam1 {
public static void main(String[] args){
//메소드가 시작된 시간을 구하기 위함long startTime = System.currentTimeMillis();
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("src/javaIO/exam/ByteExam1.java");
fos = new FileOutputStream("byte.txt");
int readCount = -1;
byte[] buffer = new byte[512];
while((readCount = fis.read(buffer))!= -1){
fos.write(buffer,0,readCount);
}
} catch (Exception e) {
// TODO Auto-generated catch blocke.printStackTrace();
}finally{
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch blocke.printStackTrace();
}
try {
fis.close();
} catch (IOException e) {
// TODO Auto-generated catch blocke.printStackTrace();
}
}
//메소드가 끝났을때 시간을 구하기 위함.long endTime = System.currentTimeMillis();
//메소드를 수행하는데 걸린 시간을 구할 수 있음.System.out.println(endTime-startTime);
}
}