다음 코드 조각은 잘 작동하며 많은 프로젝트에서 사용하고 있습니다. 그러나,이 하나의 프로젝트에 대해 예외가 발견되지 않는 파일이 있습니다.파일을 찾을 수 없습니다 예외, 코드 조각은 다른 프로젝트에서 완벽하게 작동합니다
FileInputStream myInput = new FileInputStream(
System.getProperty("user.dir") + inputFile);
w = Workbook.getWorkbook(myInput);
// w = Workbook.getWorkbook(new File(inputFile));
// w = Workbook.getWorkbook(new File(System.getProperty("user.dir"),
// inputFile));
이는 C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\application
폴더에 파일을 업로드 :
try {
FileInputStream is = new FileInputStream(file);
String original = file.getName();
Logger.debug("Filename in upload pf %s ", original);
IOUtils.copy(is, new FileOutputStream(Play.getFile(original)));
PfParser p1 = new PfParser();
p1.read(original, month, year);
Payroll.index();
} catch (FileNotFoundException e) {
Logger.error(e, "Exception in uploadSheet: ");
e.printStackTrace();
} catch (IOException e) {
Logger.error(e, "Exception in uploadSheet: ");
e.printStackTrace();
}
이
내가 주석 처리되어 몇 가지 조합을 시도 읽기 방법이다.Jexcel을 사용하여 Excel 파일을 읽으려고합니다. 서버에 표시되는 오류 :
java.io.FileNotFoundException: foo.xls (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
다른 줄 (주석 처리)을 시도하면 오류가 다양합니다.
java.io.FileNotFoundException: C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\foo.xls (The system cannot find the file specified)
나는 절대 경로 및 상대 경로와 관련된 문제를 이해하고 있지만 해결책을 찾지 못하는 것 같습니다. Ubuntu 인 로컬 컴퓨터에서 코딩 및 테스트를하는 동안 오류가 발생하지 않습니다. Windows 서버에 배포 할 때만 이러한 문제가 발생합니다.
감사합니다.
googled도 많이 있었고 vogella의 솔루션도 도움이되지 않았습니다. – theTuxRacer