📄 readfile.java
字号:
package com.unimas.dbsync.output;
import com.unimas.dbsync.entity.Recordbean;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
/**
* Created by IntelliJ IDEA.
* User: 孔加亮
* Date: 2008-12-9
* Time: 21:23:14
*/
/**
* 读取文件中的数据到数据库
*/
public class ReadFile {
public void readFile(Recordbean rb) throws IOException {
/**
*@throws IOException
*/
int count = 0;
String line;
String s1 = "";
String s2 = "";
BufferedReader in = new BufferedReader(new FileReader("d://file1.txt"));
while ((line = in.readLine()) != null) {
if (line.trim().equals("")) {
in.readLine();
break;
} else {
count++;
s1 += line + "\n";
}
}
while ((line = in.readLine()) != null) {
s2 += line + "\n";
}
rb.setTabColumnName(s1);//将处于文件首部的表字段信息读出
rb.setRecords(s2);
rb.setCount(count);
in.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -