62,620
社区成员
发帖
与我相关
我的任务
分享public class ParseFileTxt {
FileInputStream fi = null;
BufferedReader br = null;
String newFilePath = "";
File newFile = null;
FileWriter fw = null;
BufferedWriter bw = null;
public ParseFileTxt() throws Exception {
fi = new FileInputStream("D:\\file\\wttick.txt");
br = new BufferedReader(new InputStreamReader(fi,"GB2312"));
newFilePath = "D:\\file\\NewFile\\newWttick.txt";
newFile = new File(newFilePath);
fw = new FileWriter(newFile, true);
bw = new BufferedWriter(fw);
}
public static void main(String[] args) throws Exception{
ParseFileTxt parseFile = new ParseFileTxt();
parseFile.parseFile();
}
private void parseFile()throws Exception {
String temp = "";
while(true){
String line ="";
byte[] cbuf = new byte[1024 * 256];
//首先读取数据241个字节
int num = fi.read(cbuf, 0, 272);
if(num<0){
break;
}
//首先读取数据241个字节
String str1 = new String(cbuf,0,15 , "GB2312").trim();
String str2 = new String(cbuf,17,20, "GB2312").trim();
String str3 = new String(cbuf,38,10 , "GB2312").trim();
String str4 = new String(cbuf,49,10 , "GB2312").trim();
String str5 = new String(cbuf,60,12 , "GB2312").trim();
String str6 = new String(cbuf,80,17 , "GB2312").trim();
String str7 = new String(cbuf,101,11 , "GB2312").trim();
String str8 = new String(cbuf,113,9 , "GB2312").trim();
String str9 = new String(cbuf,124,13 , "GB2312").trim();
String str10 = new String(cbuf,143,9 , "GB2312").trim();
String str11 = new String(cbuf,155,7, "GB2312").trim();
String str12 = new String(cbuf,164,8 , "GB2312").trim();
String str13 = new String(cbuf,174,16 , "GB2312").trim();
String str14 = new String(cbuf,195,15 , "GB2312").trim();
String str15 = new String(cbuf,215,27 , "GB2312").trim();
line = str1 + "\t" + str2 + "\t" +str3 + "\t" +str4 + "\t" +str5 + "\t" +str6
+ "\t" +str7 + "\t" +str8 + "\t" +str9 + "\t" +str10 + "\t" +str11 + "\t" +str12
+ "\t" +str13 + "\t" +str14 + "\t" + str15 ;
bw.write(line);
bw.newLine();
System.out.println(line);
bw.flush();
}
}
112.5.235.135 其他客户端 20130513 00:03:14 13075997362 取得预设帐号 00:03:14 处理成功
112.5.235.135 Gphone手机 20130513 00:03:22 6097976 客户校验 00:03:22 处理成功 13075997362
117.136.17.56 其他客户端 20130513 00:03:29 13908517304 取得预设帐号 00:03:29 处理成功
117.136.17.56 Gphone手机 20130513 00:03:37 66155 客户校验 00:03:37 处理成功 13908517304
211.139.92.12 其他客户端 20130513 00:06:03 18293613691 取得预设帐号 00:06:03 处理成功
211.139.92.12 Gphone手机 20130513 00:06:11 10071877 客户校验 00:06:11 处理成功 18293613691
117.136.39.65 其他客户端 20130513 00:06:49 15012745498 取得预设帐号 00:06:49 处理成功
117.136.39.65 Gphone手机 20130513 00:07:19 80040879 客户校验 00:07:19 处理成功 15012745498
202.100.77.210 Gphone手机 20130513 00:08:12 10037730 委托买入 00:08:12 处理成功 15309475358 600609 3.84 2000 A553975592 1746 1746
117.136.9.60 mobile手机 20130513 00:09:45 15910136780 取得预设帐号 00:09:45 处理成功 15910136780
117.136.9.60 mobile手机 20130513 00:09:46 15910136780 取得预设帐号 00:09:46 处理成功 15910136780 00:12:45 处理成功 112.5.235.135 其他客户端 20130513 00:03:14 13075997362 取得预设帐号 00:03:14 处理成功
112.5.235.135 Gphone手机 2013051 00:03:2 6097976 客户校验 00:03:2 处理成 1307599736
117.136.17. 其他客户端 20130 13 00:03 29 1390851 取得预设帐? 00:03 29 处理 功
117.136.1 56 Gphone手机 201 0513 00: 3:37 66155 客户校验 00: 3:37 处 成功 139085
211.139 2.12 其他客户端 2 130513 0 :06:03 182 取得预? ? 0 :06:03 理成功
211.1 .92.12 Gphone手? 20130513 00:06:11 1 客户? 00:06:11 处理成功 18 691
117 36.39.65 其他客? 端 20130513 00:06:49 5498 取? 枵屎? 00:06:4 处理成功
1 .136.39.65 Gphon 手机 201305 3 00:07:19 879 ? Q? 00:07 9 处理成功 2745498
int num = fi.read(cbuf, 0, 274);