1002 285 14 298 15 336 210123 293 14 321 300114 161 1680101 1610200**** 82 82 750109 150 13001420143015701390121 158 1620103 1580157 171 180 187 191//
#################################################################################
1003 95 9 91 9 292 220217 101 8 276 310215 1 158 1610201 1580300**** 82 82 820243 147 12701350143021401350300 156 1590206 1560258 170 178 185 189//
#################################################################################
1004 61 11 49 13 40 170356 62 12 6 210349 1 157 1590315 1570357**** 97 97 820301 173 15201340137031001340353 158 1580340 1560302 169 176 183 188//
#################################################################################
1005 348 14 342 13 62 140420 349 16 73 190418 157 1580441 1570410**** 86 86 850453 153 13401350138045401310421 157 1590443 1560424 168 175 182 187//
#################################################################################
1006 336 19 324 18 305 180552 352 19 304 310539 154 1570501 1540600**** 85 85 810506 149 12901380139055201350515 155 1570501 1550600 167 174 181 186//
#################################################################################
1007 279 10 313 8 326 190607 267 13 324 250605 156 1560658 1530628**** 75 75 750700 133 11201420142065801360647 159 1590700 1540602 167 173 180 185//
##################################################################################
1008 292 17 292 18 279 220750 307 16 259 310736 2 154 1560702 1540800**** 96 96 740706 168 14801500150075801420707 161 1620744 1590701 168 172 179 184//
##################################################################################
1009 11 1 326 6 285 200832 312 3 270 280828 1 155 1550900 1530810**** 100 100 960801 176 15501570158085101500807 170 1730847 1610805 171 173 178 183//
#################################################################################
1010 351 17 10 14 31 150926 1 17 349 220958 2 157 1580957 1550901**** 96 96 950959 171 15101550157090101520955 171 1760935 1690908 175 174 178 182//
#################################################################################
1011 359 27 5 30 8 351055 338 24 352 461042 36 140 1571001 1401100**** 100 100 961001 160 14001570161103001541001 158 1711001 1561055 169 174 179 183//
###################################################################################
1012 239 8 248 11 5 301101 225 11 301 331112 19 143 1431200 1401102**** 100 100 991157 163 14301560160110901541144 175 1771151 1581101 174 173 178 182//
这个表示分行###################################################################################
将上述拷贝到文本文档里,每一行的各个数字之间都相对固定.
对其做相应的处理,并存入数据库.
//这些不算什么程序,只是一些语法的堆叠,希望自己以后改进,,
//希望大虾的指点.
以下是处理源代码v1.1
import java.io.*;
import java.sql.*;
import java.lang.Exception;
public class dealstring
{
public static void main(String[] args)throws Exception
{
try{
File read = new File("c://1.txt");
File write = new File("c://2.txt");
BufferedReader br = new BufferedReader(new FileReader(read));
BufferedWriter bw = new BufferedWriter(new FileWriter(write));
String temp = null;
temp = br.readLine();
String DBDriver = "org.gjt.mm.mysql.Driver" ;
String Url = "jdbc:mysql://localhost:3306/test";
String Uid = "root";
String Pwd = "000000";
Connection conn = null;
PreparedStatement pstmt=null;
try {
Class.forName(DBDriver);
//System.out.println ("driver is ok!");
conn = DriverManager.getConnection(Url,Uid,Pwd);
pstmt = conn.prepareStatement("insert into about (date,time,fx,fs,qw,yl) values(?,?,?,?,?,?)");
}
//捕获加载驱动程序异常
catch ( ClassNotFoundException cnfex )
{
System.err.println( "装载 JDBC/ODBC 驱动程序失败。" );
cnfex.printStackTrace();
System.exit( 1 ); // terminate program
}
//捕获连接数据库异常
catch ( SQLException sqlex )
{
System.err.println( "无法连接数据库" );
sqlex.printStackTrace();
System.exit( 1 ); // terminate program
}
while(temp != null)//一行一行读取文件
{
int e=0;
String n=temp.substring(0,2);
String o=temp.substring(2,4);
String p=temp.substring(32,37);//五个字符包括32,不包括37
String q=temp.substring(37,41);
String r=temp.substring(52,56);
String s=temp.substring(57,61);
String t=temp.substring(55,56);
char pp=t.charAt(0);
int a=Integer.parseInt(n.trim());// String to Integer
int b=Integer.parseInt(o.trim());
int c=Integer.parseInt(p.trim());
int d=Integer.parseInt(q.trim());
int f=Integer.parseInt(s.trim());
pstmt.setInt(1, a);
pstmt.setInt(2, b);
pstmt.setInt(3, c);
pstmt.setInt(4, d);
pstmt.setInt(5, f);
if(!Character.isWhitespace(pp))
{
e=Integer.parseInt(r.trim());
}
pstmt.setInt(6, e);
int rowCount = pstmt.executeUpdate();
temp = br.readLine();
}
bw.close();
br.close();
}//文件try
catch(FileNotFoundException e)
{ //文件未找到
System.out.println (e);
}
catch(IOException e)
{
System.out.println (e);
}
}
}