java读取文件内容到oracle

来源:百度知道 编辑:UC知道 时间:2024/05/30 15:14:00
REPORT: DFERROR GENERATED: 10 JUN 2005 12:34 RUN: PAGE 1
日期 :20030210 调整批量处理

卡号 姓名 交易类型 补帐/撤销 币种 调整金额 需调整金额
原始交易金额 原始交易信息 交易描述 处理结果

1111111111111111 eeeee 1000 补帐 001 0.00 100.00-
0.00 /0000/000/00000000 币种非法
1111111111111112 wwwww 1000 补帐 001 0.00 100.00-
0.00 /0000/000/00000000 币种非法

把前面几行标题去掉,读取数据到数据库表,注意的是现在一条数据是两行,需要把两行处理成一行

public static void main(String args[]) throws Exception {
// 数组的长度是一行记录的字段数,数组的每个值分别表示该字段的长度
// 根据你的文件要求改
int[] RecordStructure = new int[] { 16, 5, 4, 2, 3, 4, 6, 4, 19, 4 };
InputStreamReader b = new InputStreamReader(new FileInputStream(
new File("d:/test.txt")), "gbk");
// 最终结果
List<List> result = new ArrayList<List>();
// 存放一整条记录的中间变量
List<String> date = new ArrayList<String>();
int i = 0;
// 设置缓存区,记录中单个数据的长度不可超过缓存区的长度
String temp = "";
// 字段位置标志,范围:[0-你的字段数]
int fieldPosition = 0;
//标题的字符的行数 这里可以改!!!
int labelLength = 6;
BufferedReader a = new BufferedReader(b);
for(int j = 0; j < labelLength; j++) {
a.readLine();
}
while (true) {
i = a.read();
if (i == '\r' || i == '\n') {
continue;
} else {
temp += (char) i