티스토리 뷰

Java Application 을 통해 UTF-8 인코딩의 텍스트 파일을 생성하기 위한 코드입니다.
public static void main(String[] args) {
	try {
		String srcText = new String("UTF-8 파일을 생성합니다.");

		File targetFile = new File("D:\\output.txt");
		targetFile.createNewFile();

		BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(targetFile.getPath()), "UTF8"));

		output.write(srcText);
		output.close();
	} catch(UnsupportedEncodingException uee) {
		uee.printStackTrace();
	} catch(IOException ioe) {
		ioe.printStackTrace();
	}
}

위 코드를 실행하여 얻은 output.txt 를 에디트 플러스나 울트라 에디트로 열어보면 UTF-8 로 생성되어 있습니다.
공지사항