100分再次求教java文件操作 补充:该Bean用于Web应用程序中,指定目录后是否会抛出安全异常?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这里的路径都是以服务端的默认目录为基础: //建立目录路径 private String buildDirPath(String dirName){ String path = request.getRealPath("/"); path += "\\dirName"; File dirName = new File(path); //检查目录是否存在 if(!dirName.exists()){ dirName.mkdir(); }return path; } //写文件 public void writeData(String str,String path){ try{ FileWriter fw = new FileWriter(path + "\\" + "name.txt",true); BufferedWriter bw = new BufferedWriter(fw); bw.write(str); bw.newLine(); bw.flush(); fw.close(); }catch(IOException e){ } } 被纠结,求解释~ 高手请教!GZIP解压的问题 大家看看这个怎么做? 散個分 請教下- log4j 為啥叫這個名字呢? 如何查找某字符串在整个字符串里的所有位置 this的疑惑 很好玩的一个Applet问题,哪位会??? java swing 下实现文件上传????? 请推荐几本经典的VJ++的书给小妹,万分感激!!!! 30岁了,你还在编程?欢迎讨论 高分求 JDBC多事务的实例 prepareStatement的问题?
//建立目录路径
private String buildDirPath(String dirName){
String path = request.getRealPath("/");
path += "\\dirName";
File dirName = new File(path);
//检查目录是否存在
if(!dirName.exists()){
dirName.mkdir();
}
return path;
}
//写文件
public void writeData(String str,String path){
try{
FileWriter fw = new FileWriter(path + "\\" + "name.txt",true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(str);
bw.newLine();
bw.flush();
fw.close();
}catch(IOException e){ }
}