티스토리 뷰

public static void main(String[] args) throws IOException {
  long startTime = System.currentTimeMillis();
  String path = "파일경로";
  String copyPath = "파일경로";
  FileInputStream fis = null;
  FileOutputStream fos = null;
  
  try {
   fis = new FileInputStream(path);
   fos = new FileOutputStream(copyPath);
   
   int res = -1; //파일의 끝에 도달하면 -1반환
   while((res = fis.read()) != -1){ //읽어오는 메서드(read)
    fos.write(res); //읽어온 값을 작성하는 메서드(write)
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } finally {
   if(fis != null){
    fis.close();
   }
   if(fos != null){
    fos.close();
   }
  }
  long endTime = System.currentTimeMillis();
  System.out.println("소요시간 : "+(endTime - startTime));
 }

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함