com.yuyenews.easy.util.FileUtil Maven / Gradle / Ivy
The newest version!
package com.yuyenews.easy.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 文件工具类
* @author yuye
*
*/
public class FileUtil {
/**
* 根据文件路径 获取文件中的字符串内容
* @param path luj
* @return dux
*/
public static String readFileString(String path) {
try {
InputStream inputStream = FileUtil.class.getResourceAsStream(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
StringBuffer sb = new StringBuffer();
String str = "";
while ((str = reader.readLine()) != null)
{
sb.append(str);
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}