读取txt文本的内容数据工具类
public static List<String> fileToData()
{
List<String> list= new ArrayList<>();
BufferedReader br = null;
try
{
br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\xx.txt")), "GBK"));//UTF-8
String str = null;
int i = 0;
while ((str = br.readLine()) != null)
{
if (StrUtil.isNotBlank(str))
{
list.add(str);
}
i++;
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return list;
}