linux主机读取.txt文件内容
2017-12-20 20:59
363 查看
//filePath = /home/file/webservice/kis/pubw.txt public static void readTxt(String filePath){ try { String encoding="GBK"; File file=new File(filePath); if(file.isFile() && file.exists()){ //判断文件是否存在 InputStreamReader read = new InputStreamReader( new FileInputStream(file),encoding);//考虑到编码格式 BufferedReader bufferedReader = new BufferedReader(read); String lineTxt = null; while((lineTxt = bufferedReader.readLine()) != null){ //System.out.println(lineTxt); String mrDetail[] = lineTxt.split("\\|"); //String hour = mrDetail[0].substring(8, 10); String minute = mrDetail[0].substring(10, 12); } read.close(); //JSONArray array = JSONArray.fromObject(mrList); //System.out.println("json-->"+array.toString()); //writeTxtFile(array.toString()); }else{ System.out.println("找不到指定的文件"); } } catch (Exception e) { System.out.println("读取文件内容出错"); e.printStackTrace(); } }
相关文章推荐
- 【示例】Hibernate中读取txt的文件内容并插入到数据库
- C格式化读取txt文件内容
- C++从指定目录读取txt文件内容
- 将TXT文件上传的服务器上并将读取内容绑定到DataTable进行验证
- java 读取txt文件内容(二)
- JAVA 创建TXT文件,写入文件内容,读取文件内容
- c# 读取txt文件内容
- c#如何读取txt文件内容
- java实现读取txt文件中的内容
- java读取txt文件内容
- JAVA实现读取txt文件内容的方法
- [zz]怎样用C#读取TXT文件内容并修改
- java读取excel、txt 文件内容,传到、显示到另一个页面的文本框里面。
- c语言实现读取txt文件内容到结构体数组中
- js下Ajax读取txt文件内容
- js创建并读取txt文件的内容
- 读取本地txt文件内容
- C#生成PDF文档,读取TXT文件内容
- Java读取TXT文件内容的方法
- Node.js 读取TXT文件内容 fs.readFile()