This following scippet works well, and I have been using it across many projects. However, for this one project, I get a file not found exception.
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();
}
This is the read method, where I have tried a few combinations, which are commented out:
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));
This uploads the file to the C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\application
folder.
I am trying to read an excel file using Jexcel. The error I get on my server:
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)
Trying the other (commented out) lines, only gives a variation in the error.
java.io.FileNotFoundException: C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\foo.xls (The system cannot find the file specified)
I understand its a problem related with absolute and relative paths, but cant seem to find a solution. I do not get any errors, while coding and testing on my local machine which is Ubuntu. Its only when I deploy to a Windows server, do I get these problems.
Thanks.