您的位置:首页 > 数据库

读取文本.EFZ文件数据,存入数据库

2017-09-14 16:49 471 查看

9.13-9.14小任务

编写Java程序,将AI201608271800.EFZ文件进行解析,并将解析后的数据进行入库(入至Oracle中):

主要技术点:读取.efz文件并每俩行取一次数据存入数据库。

public static void main(String[] args) throws IOException {
System.out.println("数据扫描插入中---------");
AtmosphereDao atd = new AtmosphereDao();
File file = new File("e:/AI201608271800.EFZ");
FileReader fr = new FileReader(file);
BufferedReader in = new BufferedReader(fr);
String line;
int count = 1;
int sum = 0, n = 0;
String[] str1= {};
String[] str2= {};
while ((line = in.readLine()) != null) {
if (count % 3 == 1) {
str1 = line.split(" ");
} else if (count % 3 == 2) {
str2 = line.split(" ");
} else if (count % 3 == 0) {
Atmosphere asp = new Atmosphere(str1[0],Integer.parseInt(str1[1]) ,Integer.parseInt(str1[2]),str1[3] , str1[4], Integer.parseInt(str1[5]),str2[0], str2[1], str2[2],
str2[3], str2[4], str2[5], str2[6], str2[7], str2[8], str2[9], str2[10], str2[11], str2[12], str2[13],
str2[14], str2[15], str2[16], str2[17], str2[18], str2[19], str2[20], str2[21], str2[22], str2[23], str2[24],str2[25], str2[26], str2[27], str2[28], str2[29], str2[30], str2[31], str2[32], str2[33], str2[34], str2[35],str2[36], str2[37], str2[38], str2[39], str2[40], str2[41], str2[42], str2[43], str2[44], str2[45], str2[46],str2[47], str2[48], str2[49], str2[50], str2[51]);

n = atd.InsertAll(asp);
sum += n;
System.out.println("插入第" + sum + "条数据");

}
count++;

}
System.out.println("数据插入完毕");
in.close();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐