I am creating a file like so
try {
File file = new File(workingDir, obj.getName() + \".xls\");
outputStream = new FileOutputStream(file);
} catch (FileN
Maybe it's because of the backslashes in the path? Path too long? File name invalid for this error (special caracters...) ?
I might be totally wrong, but worth a try since it sounds like a OS dependent error.
Make sure the user that runs the JVM process has the right permissions to access that file.
Perhaps the application doesn't have the correct access to write to the file? Is it read-only or otherwise protected?
FileOutputStream.open()
is a native method, I would assume any sort of exception message such as "The parameter is incorrect" is coming from the underlying OS.
BTW: the File
constructor does not call FileOutputStream.open()
, so is the exception not actually coming from the code you posted here?
It appears to be an issue with the path you're using. Try using file.getPath() before you open it to debug what is going on with your path.
File file = new File(workingDir, obj.getName() + ".xls");
System.out.println("Path="+file.getPath());
outputStream = new FileOutputStream(file);
This looks like a reported bug on Windows machines.
Under normal situations, something like a path that has a colon (:) in it which does not refer to a drive letter would cause this message.
If your "workingDir" is a relative path, then are you sure you are on the correct "current directory" when you moved your app from unix to windows? Maybe, you should check what the current directory of the running application is.