设为首页 加入收藏

TOP

Java中IO写文件工具类(二)
2014-11-23 22:10:03 来源: 作者: 【 】 浏览:40
Tags:Java 文件 工具

File file = new File(filePath);

if(!file.exists()){
boolean tempFlag = file.mkdirs();
if(!tempFlag){
log.error("文件夹"+filePath+"创建失败");
return;
}
}

file = new File(filePath,filename);


if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(filePath+filename, flag);
OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
for (String temp : fileContent)
osw.write(temp + "\r\n");
osw.flush();
osw.close();
}


--------------------------------------分割线 --------------------------------------


--------------------------------------分割线 --------------------------------------


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Java日期工具类 下一篇Lucene给文本索引和搜索功能的应用

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: