Created
March 3, 2013 02:49
-
-
Save mizuneko/5074264 to your computer and use it in GitHub Desktop.
ファイルへの書き出し
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String path = "C:/dir/to/my/file/myfile.txt"; | |
String encoding = "Windows-31j"; | |
// 出力ストリームを開く | |
PrintWriter writer = new PrintWriter( | |
new OutputStreamWriter(new FileOutputStream(path), encoding)); | |
// ファイルへ文字列を書き出す | |
try { | |
writer.println("This is test."); | |
writer.println("This is test test."); | |
writer.println("This is test test test."); | |
} finally { | |
try { writer.close(); } catch(Exception e) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment