a2zfilewriter.java
来自「complete bayesian spam filter (java sour」· Java 代码 · 共 34 行
JAVA
34 行
/* Daniel Shiffman *//* Programming from A to Z *//* Spring 2006 *//* http://www.shiffman.net *//* daniel.shiffman@nyu.edu */package a2z;import java.io.FileOutputStream;import java.io.IOException;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;public class A2ZFileWriter { private String filename; public A2ZFileWriter(String name) { filename = name; } public void writeContent(String content) throws IOException { // Create an output stream and file channel // Using second argument as file name to write out FileOutputStream fos = new FileOutputStream(filename); FileChannel outfc = fos.getChannel(); // Convert content String into ByteBuffer and write out to file ByteBuffer bb = ByteBuffer.wrap(content.getBytes()); //outfc.position(0); outfc.write(bb); outfc.close(); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?