public void content(String str)
{
String path = getPath();
String strs = str; //添加的内容
String Dpath = getPath() + "\\content\\"; //文件夹保存在应用程序的启动路径下
String Fpath = Dpath + "\\content" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".txt";//文件路径
try
{
File Dfile=new File(Dpath);
if (!Dfile.exists() && !Dfile.isDirectory())
{
Dfile.mkdir();
}
File Ffile=new File(Fpath);
if(!Ffile.exists())
{
try {
Ffile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
FileWriter fw=nul
java-往txt文档写入内容
最新推荐文章于 2024-05-06 09:01:24 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)