具体你要问的晌乎是什么?
IO流? 向文件写东西?
fileoutputstream fos=new fileoutputstream(filepath,true);
注意后郑则面那个参数,代表追加喊谨棚模式,即不删除原文件,直接在文件后面添加
用bwriter.write(str);然后bwriter.newLine();一行一行的写数据。你先岁旦创建f:\a.txt ,里面放一些歼雀猛数据试试运行一下程序。
try
{
File file1 = new File("f:\氏桥\a.txt");
File file2 = new File("f:\\b.txt");
FileWriter writer = new FileWriter(file2);
FileReader reader = new FileReader(file1);
BufferedWriter bwriter = new BufferedWriter(writer);
BufferedReader breader = new BufferedReader(reader);
String str = null;
int i = 1;
while((str = breader.readLine()) != null)
{
if(i++ % 2 != 0)
{
bwriter.write(str);
bwriter.newLine();
}
}
bwriter.close();
breader.close();
writer.close();
reader.close();
}
catch(Exception e)
{
e.printStackTrace();
}
*.append();