개발도 하냐?
EUC-KR을 UTF-8로 변환하는 절차
chaeya
2011. 1. 18. 13:19
반응형
뭐 여러가지 방법이 있겠지만
그 안의 절차를 살펴보죠
import java.io.*; public class Foo { public static void main(String[] args) { if (args.length == 0) { // args.length 는 옵션 개수 System.err.println("Input Filename..."); System.exit(1); // 읽을 파일명을 주지 않았을 때는 종료 } String outFilename = args[0] + ".uni"; // 출력 파일명 만들기, uni 라는 확장자를 붙여서 try { //////////////////////////////////////////////////////////////// BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream(args[0]), "MS949" ) ); BufferedWriter out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(outFilename), "UTF-8" ) ); String s; while ((s = in.readLine()) != null) { out.write(s); out.newLine(); } in.close(); out.close(); //////////////////////////////////////////////////////////////// } catch (IOException e) { System.err.println(e); // 에러가 있다면 메시지 출력 System.exit(1); } } }
반응형