-1
txt文件讀取和1〜3行是發送Mesaage和3〜6線讀取信息發送 但1〜3個後讀發送,下一個再次1〜3行之後發送讀... 我想3號線讀取TXT文件重複3線從txt文件讀
的test.txt
1|11221234|c1|c2|c3|c4 2|11221234|c1|c2|c3|c4 3|11221234|c1|c2|c3|c4 4|11221234|c1|c2|c3|c4 5|11221234|c1|c2|c3|c4 6|11221234|c1|c2|c3|c4 7|11221234|c1|c2|c3|c4 8|11221234|c1|c2|c3|c4 9|11221234|c1|c2|c3|c4 9|11221234|c1|c2|c3|c4 10|11221234|c1|c2|c3|c4 11|11221234|c1|c2|c3|c4 12|11221234|c1|c2|c3|c4 13|11221234|c1|c2|c3|c4
while ((s = in.readLine()) != null) {
cnt++;
Element record = new Element("RECORD");
String[] arr = s.split("│");
if (arr.length == tableInfoMap.size()) {
for (int i = 0; i < arr.length; i++) {
int j = i + 1;
String fieldName = (String) tableInfoMap
.get("COLUMN" + j);
Element field = new Element(fieldName);
field.addContent(new CDATA(arr[i]));
record.addContent(field);
}
} else {
throw new ArrayIndexOutOfBoundsException(" ");
}
rootElement.addContent(record);
if (cnt >= 3) {
sendMsg(srcTblName, tgtTblName, classPath,
className, doc, comm, sndAgency, rcvAgency,
cnt);
cnt = 0;
}
}
if (cnt > 0) {
boolean isSend = sendMsg(srcTblName, tgtTblName,
classPath, className, doc, comm, sndAgency,
rcvAgency, cnt);
in.close();
if (isSend == true) {
File f = new File(file);
if (f.delete() == true) {
logger.info("Send File Success: " + file);
logger.debug(f.getPath());
} else {
logger.warn("Send File Fail: " + file);
logger.debug(f.getPath());
}
}
}
請格式化您的代碼。你還需要添加更多關於你的問題的具體信息,比如你得到了什麼錯誤等等。 – ohlmar