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());
}
}
JAVA 解析TXT文本的更多相关文章
- 使用java读取解析txt文本数据,管理简单的数据
在实际开发中会经常碰到使用编程语言读取文本文件的内容,这内容可以是各种各样的一下本人写出我自己做的一个读取文本文件的例子,文件中存储的是我的个人网站 www.yzcopen.com 导航栏目因为懒得使 ...
- java操作txt文本(二):删除文本括号内的内容
想法由来:之前写读书报告时,遇到一些烦人的文献,总喜欢把注释作为括号内容放到正文中,使文章繁琐冗长,所以写了下面这个代码,剔除了括号内的内容. 适用条件:原txt文本中的括号使用正确,即左右括号匹配正 ...
- java操作txt文本(一):遇到指定字符换行
想法由来:有时查看网页源代码的css文件内容,竟是恼人的压缩后代码(不换行),如下图所示-- 它的可读性很差,所以写了下面这个简单的程序,实现自动换行. 适用条件:遇到指定字符换行(本例中遇到'}'换 ...
- 解析txt文本,dom4j工具输出为xml文档
有如下一个ttl.txt文本文档,每一行用空格隔开的三段分别代表主谓宾, 要将它们输出为xml格式文档 工具:dom4j,jar包导入MyEclipse的Java Project工程 代码如下: pa ...
- java导出txt文本
页面 项目结构 html代码 <html> </head> <body> <form action="down/downLoad" met ...
- JAVA读取TXT文本中的数据
现在在Demo.txt中存在数据: ABC 需要将ABC从文本文件中读取出来 代码片: import java.io.*; class FileReaderDemo { public static v ...
- java 解析txt/html文件
package util.read; import java.io.BufferedReader;import java.io.FileReader; public class ReadFromFil ...
- [java] java解析txt文件
/** * 读取txt文件内容封装为map返回 * @param filePath * @return */ public static String readTxt(String filePath) ...
- java 解析富文本处理 img 标签
很多项目都需要到富文本来添加内容,就好比新闻啊,旅游景点之类的,都需要使用富文本去添加数据,然而怎么我这边就发现了两个问题 1)怎样将富文本的图片的 src 获取出来? 2)后台上传的时候用的是相对路 ...
随机推荐
- Non-Local Image Dehazing 复现
本文选自CVPR 2016, 文章链接Dana Berman, Tali Treibitz, Shai Avidan. Non-Local Image Dehazing 复现源码见我的Github 无 ...
- 常用Build-in Keywords
1. Variables |- Set variable |- Create list |- Evaluate |- Get Variable Value 2. Conditional |- Run ...
- 4.tar的各个参数详解
转于:https://blog.csdn.net/liuyundemhsg/article/details/52525028 参数:-c :建立一个压缩文件的参数指令(create 的意思):-x : ...
- C语言基础语法
#include <stdio.h> int main() { int age; printf("input your age"); scanf("%d&qu ...
- 利用ImageOps调整图片的Aspect Ratio(给图片添加borders)
# -*- coding: utf-8 -*- #******************** # 改变图片的纵横比(aspect retio) # 使用ImageOps.expand() # Image ...
- SpringMVC之@RequestParam @RequestBody @RequestHeader 等详解
转自:http://blog.csdn.net/kobejayandy/article/details/12690161?reload 简介: handler method 参数绑定常用的注解,我们根 ...
- 安装MySQL5.7由于 Redistributable导致失败
今天上午安装MySQL5.7时一直提示 1: Action 10:59:21: INSTALL. 1: 1: MySQL Server 5.7 2: {F08E9C75-A42E-4962-8760- ...
- [LeetCode] 329. Longest Increasing Path in a Matrix ☆☆☆
Given an integer matrix, find the length of the longest increasing path. From each cell, you can eit ...
- 【Foreign】tty的方程math [数学]
tty的方程math Time Limit: 50 Sec Memory Limit: 128 MB Description 给定n.m.k.p. a+b+c=n, a^2+b^2+c^2=m, a ...
- 写给“有钱大爷”、”美工殿下”、“前端文艺青年”的微信HTML5页面设计建议
============================== 2018更新 iphone X 的设计内容 ============================== 我保证你一分钟就 ...