달력

5

« 2024/5 »

  • 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

'Basic Languages/Java'에 해당되는 글 12

  1. 2016.12.12 자바 파일 캐릭터 단위로 복사하기

public class FileCopy {

public static void fileCopy(String input, String output){

FileReader fr = null;

FileWriter fw = null;

int i;

try {

fr = new FileReader(input);

fw = new FileWriter(output);

while((i = fr.read()) != -1){

System.out.print(i);

fw.write(i);

}

} catch (IOException e) {

e.printStackTrace();

}finally{

try {fr.close();} catch (IOException e) {e.printStackTrace();}

try {fw.close();} catch (IOException e) {e.printStackTrace();}

}

}


public static void main(String[] args) {

fileCopy("input.txt", "output.txt");

}

}

:
Posted by 클레잇