0

My requirement is to create a file in the server in Java. I initially tried with the code given below:

File file = new File(<path in the server>);
file.createNewFile(); --- raises an exception

But when I am giving a path in server I am getting an exception

java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)

Any help or suggestion on how to create a file in the server would be highly appreciated.

1 Answer 1

2

No such file or directory

There are basically two cases where this happens.

  1. The file or directory doesn't exist (check the spelling).
  2. You program doesn't have the permissions required to read and write in the given Folder. (You have to check this in your file system, depending on your operating system)

UnixFileSystem.createFileExclusively

I'm pretty sure that in this case you have to set the permissions on your folder right...

Sign up to request clarification or add additional context in comments.

4 Comments

I am using the output of the SQL as the file path. select substr(value,1,decode(instr(value,','),0, length(value),instr(value,',')-1) ) from v$parameter where name = 'utl_file_dir'; I can write to this directory in PLSQL using utl_file API, is there a similar way in Java.
I suggest you explain exactly what your trying to do in Java in your question. I'm pretty sure that your database and whoever executes the Java are two different user in the System...
I have a Java program, which when run should write the SQL results into a .csv file. And this .csv file needs to reside in the server.
So check and fix the user rights (or have them fixed if you cannot) as Kuchi is trying to explain to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.