复制代码代码如下:
impor java.io.BufferedInputStream;
impor java.io.BufferedReader;
impor java.io.File;
impor java.io.FileInputStream;
impor java.io.FileWriter;
impor java.io.IOException;
impor java.io.InputStream;
impor java.io.InputStreamReader;
kelas publik qukonghang {
nama file String statis pribadi1;
nama file String statis pribadi2;
public static void main(String[] args) {
namafile1="file1";
namafile2="file2";
File file=File baru(namafile1);
InputStream adalah=null;
BufferedReader br = nol;
Tali tmp;
Penulis FileWriter=null;
ke dalam saya=0;
mencoba {
is=new BufferedInputStream(FileInputStream(file) baru);
br = new BufferedReader(new InputStreamReader(adalah, "utf-8"));
penulis = FileWriter baru (nama file2, benar);
while((tmp=br.readLine())!=null){
if(tmp.sama dengan(""));
kalau tidak{
penulis.write(tmp+"/n");
saya++;
Sistem.keluar.println(i);
}
}
penulis.close();
adalah.close();
} tangkapan (IOException e) {
e.printStackTrace();
}
}
}