以下是代码片段: try { OutputStream out = new FileOutputStream("test.txt"); out = new DataOutputStream(out); } catch(FileNotFoundException e) { e.printStatckTrace(); }
以下是代码片段: import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; /** * A new output stream, which will check the space character * and won’t write it to the output stream. * @author Magic * */ public class SkipSpaceOutputStream extends FilterOutputStream { public SkipSpaceOutputStream(OutputStream out) { super(out); } /** * Rewrite the method in the parent class, and * skip the space character. */ public void write(int b) throws IOException{ if(b!=’ ’){ super.write(b); } } }