Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typically, what does it mean when java returns a "The parameter is incorrect"

I am creating a file like so

try {
    File file = new File(workingDir, obj.getName() + ".xls");
    outputStream = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
    ex.printStackTrace();
}

And I am getting

java.io.FileNotFoundException: ..\a\relative\path\obj_name.xls (The parameter is incorrect)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)

What does "the parameter is incorrect" mean? The pathname I validated exists; shouldn't it just create the file name? This is on a windows machine. The code works without this error on unix based systems.


Update

Verified that the file exists that the output stream is attempting to write to. Also verified that the file is writable. After much fussing, I removed the actual path and just passed in the file name (not desired) and that works. So the issue has something to do with the path. Do I need to escape the characters in the path?


1 Answers

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.

like image 155
JeffH Avatar answered Oct 22 '25 01:10

JeffH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!