java.io.Writer.write()で文字ストリームに書き込むサンプル

2018年3月11日

Javaコード
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class OutputStreamWriterFileDemo {

public static void main(String[] args) {
String fileName = “C:\\test" + File.separator + “demo.txt";
File file = new File(fileName);

try {

Writer out = new OutputStreamWriter(new FileOutputStream(file));
out.write(“write data operation “);
out.close();

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}

}

}

Java

Posted by arkgame