本帖最后由 442851994 于 2012-11-1 18:13 编辑
package cn.itcast;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class fuxi7 {
public static void main(String[] args) throws IOException {
InputStream is=System.in;
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("fw.txt"));
int len=0;
StringBuilder sb=new StringBuilder();
while(true){
//System.out.println(is.read());
len=is.read();
if(len=='\r'){
continue;
}
if(len=='\n'){
bos.write(sb.toString().getBytes());
sb.delete(0, sb.length());
}else{
sb.append((char)len);
}
}
bos.close();//这句话会报错,提示出现remove,就将我这句关闭流的话删掉了??
}
}
|