String fileName1 = "/Users/macbook/java/test/IC080329.G02";
FileReader f;
BufferedReader br;
SimpleConnection sc = new SimpleConnection();
Connection con = null;
try {
f = new FileReader(fileName1);
br = new BufferedReader(f);
String strLine;
int i = 0;
con = sc.getConnection();
while ((strLine = br.readLine()) != null) {
//長度為135,為了防止表頭及表
if(strLine.length()>100){
//System.out.println("["+strLine.length()+"]"+strLine);
separate(strLine);
if(save2db(con)){
System.out.println("第"+i+"筆匯入成功!");
}
// print();
}
i++;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}finally{
sc.freeConnection(con);
}
沒有留言:
張貼留言