File file = new File("F:/hejing/InstrumentJsonData.txt");
StringBuilder localStrBulider = new StringBuilder();
if(file.isFile() && file.exists()) {
try {
InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), "utf-8");
BufferedReader bufferReader = new BufferedReader(inputStreamReader);
String lineStr = null;
try {
while((lineStr = bufferReader.readLine()) != null) {
localStrBulider.append(lineStr);
}
bufferReader.close();
inputStreamReader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("file read error!");
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
System.out.println("file catch unsupported encoding!");
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
System.out.println("file not found!");
e.printStackTrace();
}
}else {
System.out.println("file is not a file or file is not existing!");
return null;
}
System.out.println("localStrBulider.toString():" + localStrBulider.toString());
相关文章
- 08-21Matlab读取txt中用空格分隔的数据文件到矩阵
- 08-21spring读取classpath目录下的配置文件通过表达式去注入属性值.txt
- 08-21SSIS读取脚本任务上的平面文件连接
- 08-21python使用panda读取txt文件
- 08-21CodeGo.net>如何在SSIS中基于创建日期读取文件夹的所有文件?
- 08-21【SSIS】Foreach循环容器读取 xlsm 格式的文件时,连接管理器出错
- 08-21SAS初学者笔记---003---利用数据步读取数据--从文件中读取数据
- 08-21python学习——读取染色体长度(六:读取含有染色体长度的文件)
- 08-21读取图片文件、处理和保存
- 08-21Python中读取csv文件内容方法