java解析dat文件内的内容,下面是dat里的信息
ID:324,803DocTitle:15/09/25-certifytruecopyFileName:bakersam8.TIFFileDirectory:.\IMAG...
ID: 324,803
Doc Title: 15/09/25 - certify true copy
File Name: bakersam8.TIF
File Directory: .\IMAGES\baker
File Size: 1,051,268
File Date: 10/19/2015 5:32:32pm
$FILE$: d:\alchemy data - 2008\ttg_2008\IMAGES\baker\bakersam8.TIF
$FOLDER$: Bannerman Nic\Baker, Samantha Jane\Client Data\Money Laundering
File Format: TIFF
Doc Type:
Company:
A/C (az/#):
Doc Section:
Personal:
Sector:
Sub Sector:
Salesperson:
Res Country: 展开
Doc Title: 15/09/25 - certify true copy
File Name: bakersam8.TIF
File Directory: .\IMAGES\baker
File Size: 1,051,268
File Date: 10/19/2015 5:32:32pm
$FILE$: d:\alchemy data - 2008\ttg_2008\IMAGES\baker\bakersam8.TIF
$FOLDER$: Bannerman Nic\Baker, Samantha Jane\Client Data\Money Laundering
File Format: TIFF
Doc Type:
Company:
A/C (az/#):
Doc Section:
Personal:
Sector:
Sub Sector:
Salesperson:
Res Country: 展开
1个回答
展开全部
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class DatDemo {
public static void main(String[] args) throws Exception {
File file = new File("c:\\test.dat");
BufferedReader br = new BufferedReader(new FileReader(file));//输入流
String str;
while((str=br.readLine())!=null){//按行读取
String[] ss = str.trim().split(":");
if(ss.length==2){//如果包含key和value就输出
System.out.println("key="+ss[0].trim()+"\nvalue="+ss[1].trim());
}else{//只有key 没有value就输出value=null
System.out.println("key="+ss[0].trim()+"\nvalue="+"null");
}
}
br.close();//关闭流
}
}
运行测试
key=ID
value=324,803
key=Doc Title
value=15/09/25 - certify true copy
key=File Name
value=bakersam8.TIF
..........
....
.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询