package com.util;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; /**
* @ClassName: IOUtill
* @Description: I/O工具类
* @author 无名
* @date 2016-5-20 下午9:00:18
* @version 1.0
*/
public final class IOUtill
{
private IOUtill(){} public static void writeByUrl(String url,String content)
{
File file = new File(url);
if (!file.getParentFile().exists())
{
file.getParentFile().mkdirs();
}
try
{
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
try {
FileWriter fw = new FileWriter(file, true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.flush();
bw.close();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
} public static String readByUrl(String url)
{
File file = new File(url);
if (!file.getParentFile().exists())
{
file.getParentFile().mkdirs();
}
String content = "";
try
{
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
try
{
String line = br.readLine();
content += line;
while(line != null)
{
line = br.readLine();
content += line;
}
}catch (IOException ex) {
ex.printStackTrace();
}
}catch(FileNotFoundException e){
e.printStackTrace();
}
return content;
}
}

最新文章

  1. ABP源码分析三十三:ABP.Web
  2. C#设计模式——职责链模式(Chain Of Responsibility Pattern)
  3. 匹配一级分类和二级分类 名字和url 里面有玄机
  4. Jenkins: 使用groovy + job-dsl 创建并触发job
  5. JavaScript实现一个复数类
  6. spring boot / cloud (八) 使用RestTemplate来构建远程调用服务
  7. 一般处理程序(ashx)的使用
  8. 嵌入式linux——汇编、C语言基础(一)
  9. 编写shell脚本kill掉占用cpu超过90%以上的程序
  10. 关于Django部分
  11. 解决highCharts导出功能汉化问题
  12. Homestead 修改 Homestead.yaml 文件后 vagrant up 报错的问题
  13. Mysql密码忘记了怎么办?
  14. PAT甲题题解-1055. The World's Richest (25)-终于遇见一个排序的不水题
  15. excel如何快速更改表格边框的颜色
  16. centOS7 apache ssl证书安装配置
  17. mysql 8小时问题
  18. React简单实现双向数据绑定
  19. Tomcat设置是否可以上传文件到服务器
  20. Python类对象

热门文章

  1. EXCEL的导入导出
  2. 原生ajax基础
  3. Asp.net使用代码修改配置文件的节点值
  4. PPT开发 * .pps 文件类型
  5. R语言中的logical(0)和numeric(0)以及赋值问题
  6. Windows server 修改mysql端口
  7. iOS进阶_地图定位
  8. 对于git的认识
  9. 在RHEL6p5中设置网卡
  10. testng+reportng,运行xml