//Sample05_01.java import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.IOException; import java.io.UnsupportedEncodingException; class Sample05_01{ public static void main(String[] args){ String path = "hello.txt"; File file = new File(path); try { FileOutputStream outStream = new FileOutputStream(file); OutputStreamWriter writer = new OutputStreamWriter(outStream, "UTF-8"); String str = "This is hello.txt\nこんにちは。\nend"; writer.write(str, 0, str.length()); writer.close(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } } }