public void writefile(String path,String content,boolean append)
{
BufferedWriter bw;
File writefile;
boolean addStr = append;
writefile = new File(path);
if(writefile.exists()==false)
{
try {
writefile.createNewFile();
writefile = new File(path);
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
else
{
writefile.delete();
try {
writefile.createNewFile();
writefile = new File(path);
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
try {
FileWriter fw = new FileWriter(writefile,addStr);
bw = new BufferedWriter(fw);
fw.write(content);
fw.flush();
fw.close();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
还没有评论,来说两句吧...