0

I'm trying to create a directory and a file in a linux server. I have all the permissions and it works in local windows machine ("C:\home\images\784).But when I put the server url it doesn't work.

The directory is:

String directorio = "10.30.10.117:/home/images/784/"
File folder = new File(directorio);
Boolean bol = folder.mkdirs();

When the file "folder" is created it's absolute path is:

"10.30.10.117:\home\images\784"

When I want to write the file I get this exception (the directory doesn't exist)

Caused by: java.io.FileNotFoundException: 10.30.10.117:\home\images\1508-1-N.png (The filename, directory name, or volume label syntax is incorrect)

Thank you very much!

1
  • If you want to connect via SMB or CIFS to a windows server you need to use a library which supports that protocol. Commented Apr 27, 2017 at 12:52

2 Answers 2

2

Here:

String directorio = "10.30.10.117:/home/images/784/"

You seem to wrongly assume that the Java File class has the power to magically connect to a remote system in order to create a directory there.

Wrong. You can only create a file on the local file system.

Simple as that.

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

Comments

-1

If the machine "10.30.10.117" is on your local network and if you have the permission to create file on that machine then the problem is

File folder = new File("//10.30.10.117:/home/images/784/");
File file   = new File("//10.30.10.117:/home/images/784/1508-1-N.png");
folder.mkdirs();
file.createNewFile();

Before write to file create it.

But if the machine "10.30.10.117" is on external network for your machine then you can't create a file or folder directly from your machine. You need ftp connection vb...

1 Comment

Thank you. It was a usefull answer.

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.