JAVA 解析TXT文本
package file;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Date;
public class ImportFile {
public static void main(String[] args) {
System.out.println(new Date());
String path = "E:\\数据.txt"; //文件路径
File file = new File(path);
if(file.exists() && file.isFile()){
try{
InputStreamReader read = new InputStreamReader(new FileInputStream(file),"GBK"); //设置文字编码
BufferedReader bufferRead = new BufferedReader(read);
String lineText = null;
while(bufferRead.readLine() != null){
lineText = bufferRead.readLine();
String data[] = lineText.split("\t"); //本文件中按制表符分割
for(String x : data){
System.out.println(x);
}
}
read.close();
}catch(Exception e){
e.printStackTrace();
}
}
System.out.println(new Date());
}
}
最新文章
- Linux文件系统层次结构标准
- 2、C#面向对象:封装、继承、多态、String、集合、文件(上)
- 立即执行函数与window.onload作用类似
- Java异常-一般异常和运行时异常的区别
- php设计模式之单例、多例设计模式
- .Net4.0 ashx页面报错:检测到有潜在危险的Request.Form值(转)
- 嵌入式C开发人员的最好的0x10道笔试题
- UVA 10317 - Equating Equations (背包)
- PAT (Advanced Level) 1105. Spiral Matrix (25)
- 【Java SE】如何安装JDK以及配置Java运行环境
- MFC,ADO方式实现数据库操作
- [开发技巧]·TensorFlow中numpy与tensor数据相互转化
- ARM指令集详解
- springmvd接收参数问题
- mfs 使用心得
- mac 安装geckodriver和chromedriver
- 使用Tomcat部署应用
- C/C++ 二维数组
- 你对position的了解有多少?
- cmd获取批处理文件所在路径
热门文章
- 北京联通IPTV 数码视讯 Q1 破解过程
- ab输出信息解释以及Failed requests原因分析
- bzoj 1798 线段树
- kubernetes挂载ceph rbd和cephfs的方法
- Go_13:Go常用功能总结一阶段
- P2831 愤怒的小鸟
- sys模块python
- python反射,单例模式
- 路径名导致的异常:javax.imageio.IIOException: Can't read input file!
- bzoj千题计划162:bzoj2006: [NOI2010]超级钢琴