2009년 6월 29일 월요일

파일입출력-일본어

if (e.getSource() == save) {
// 일본어 SJIS    
try {
FileOutputStream fo=new FileOutputStream("out.txt");
OutputStreamWriter ow=new OutputStreamWriter(fo,"Shift_JIS");
BufferedWriter fw = new BufferedWriter(ow);
fw.write(out.getText());
fw.close();

JOptionPane.showMessageDialog(this, out.getText() + "저장되었습니다.");
} catch (IOException e1) {
e1.printStackTrace();
}

}

if (e.getSource() == load) {
try {
FileInputStream fi= new FileInputStream("out.txt");
InputStreamReader in = new InputStreamReader(fi, "Shift_JIS");
BufferedReader br = new BufferedReader(in);

String temp;
while ((temp = br.readLine()) != null) {
out.append(temp);
}

} catch (IOException e1) {
e1.printStackTrace();
}
}

댓글 없음:

댓글 쓰기