输出文件到项目
来源:互联网 发布:无纸化会议软件定制 编辑:程序博客网 时间:2024/05/14 05:51
String path = request.getSession().getServletContext().getRealPath("/statics/log/out.txt");
File out = new File(path);
System.out.println(1);
System.out.println(out.getAbsolutePath());
if (!out.exists()) {
try {
out.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println(2);
FileWriter fw = null;
BufferedWriter write = null;
try {
fw = new FileWriter(out, true);
write = new BufferedWriter(fw);
write.write("fwejfioewfewiofi");
write.newLine();
write.flush();
System.out.println("写入成功");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fw.close();
write.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
File out = new File(path);
System.out.println(1);
System.out.println(out.getAbsolutePath());
if (!out.exists()) {
try {
out.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println(2);
FileWriter fw = null;
BufferedWriter write = null;
try {
fw = new FileWriter(out, true);
write = new BufferedWriter(fw);
write.write("fwejfioewfewiofi");
write.newLine();
write.flush();
System.out.println("写入成功");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fw.close();
write.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
阅读全文
0 0
- 输出文件到项目
- 如何将项目文件输出到输出目录
- web项目中Log4j不输出到文件问题
- CreateProcess()输出到文件
- 输出到文件
- 输出时间到文件
- c++ 输出到文件
- make输出到文件
- Logcat输出到文件
- C++输出到文件
- 文件列表输出到文件
- 改变VS2008 vc项目的输出文件及中间文件到系统的临时文件夹[原]
- DBF文件输出到WORD
- XML格式化输出到文件
- log4j输出到指定文件
- 使cout输出到文件
- Android输出logs到文件
- 把图像输出到文件
- 谈谈系统架构这个东西
- excel从入门到忘记 学习心得分享(含百度网盘分享)
- mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”)的处理方法
- java作业
- MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法
- 输出文件到项目
- 拷贝构造函数和赋值运算符的重载的调用次数问题
- Dynamic Programming
- VMware Ubuntu安装详细过程(非常靠谱)
- SQL语句
- Pie(二分法+double输入用%lf,输出用%f!!!)
- 架构犹如探险,眼界必须超前
- numpy 学习
- TCP/IP网络编程学习之路一