读文件异常问题
unix系统、WebSphere
网关把文件发送到文件系统指定路径,之后文件系统监控到该目录中有文件时将把该文件发送给解析文件的线程(或许有多个),当有线程检查到文件名相匹配时就进行解析文件
在处理文件方法中的
BufferedReader br = new BufferedReader(new FileReader(oReqFile));行出错
Exception Message:
java.io.FileNotFoundException:/u02/project(Cannot open or remove a file containing a running program)
java.io.FileInputStream.open()
java.io.FileInputStream. <init> (FileInputStream.java)
java.io.FileReader. <init> (FileReader.java)
部分源码:
Class:
{
protected String psBatchID = null;
protected File poRplFile = null;
//接受文件
public void messageReceived(Object msg) {
File oTmpFile = (File) msg;
if (psBatchID != null && oTmpFile != null) {
if (oTmpFile.getName().startsWith(psBatchID)) {
poRplFile = oTmpFile;
}
}
}
//解析文件
public void performDataFeed() throws Exception {
try {
psBatchID = CommonUtil.getBatchOID();
// Generate Request File using RequestFileGenerator
File loReqFile = RequestFileGen.generateRequestFile(psBatchID);
try {
poRplFile = null;
int iCnt = iReplyTimeout / 500;
for(int i=0; i <iCnt; i++) {
if (poRplFile != null) {
break;
} else {
try {
Thread.sleep(500);
} catch (InterruptedException iex) {}
}
}
} catch (Exception ex) {
throw ex;
}
performUpload(poRplFile);
} catch (Exception ex) {
throw ex;
} finally {
psBatchID = null;
poRplFile = null;
}
}
//处理文件
public List performUpload(File oFile) {
try{
BufferedReader br = new BufferedReader(new FileReader(oReqFile));
&nb