50,530
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) throws IOException {
InputStream is = new BufferedInputStream(new FileInputStream("e:/1.txt"));
int len;
byte[]temp=new byte[1024];
StringBuffer sb=new StringBuffer();
while(-1!=(len=is.read(temp))){
String str= new String(temp, 0, len);
sb.append(str);
}
System.out.println(sb.toString());
is.close();
String str2=sb.toString();
str2=str2.replace("你想删除的东西","");
OutputStream os = new BufferedOutputStream(new FileOutputStream("e:/1.txt"));
byte[]temp2 = str2.getBytes();
os.write(temp2);
os.close();
}