problem to create a new file in remote server

A

Angel Lowelle

I have problem to create a file in remote server, I got exception when
I create a file in remote server. Maybe I couldn't do in the following
way? When I tested this code to write the file in the same server, it
is fine. I already give the write permission in the images folder. I
don't know what went wrong, please advice. thanks

File file = new File("http://another_server/images/file1");
output = new BufferedWriter(new FileWriter(file));
output.write(text);
 
A

Arved Sandstrom

I have problem to create a file in remote server, I got exception when I
create a file in remote server. Maybe I couldn't do in the following
way? When I tested this code to write the file in the same server, it is
fine. I already give the write permission in the images folder. I don't
know what went wrong, please advice. thanks

File file = new File("http://another_server/images/file1"); output =
new BufferedWriter(new FileWriter(file)); output.write(text);

The URI in this File constructor is supposed to be a file: URI. If you
have a share to this other location I expect that would work.

To do what it looks like you want to do, you really need the target
server to have a capability for file creation through some protocol.
Whether it's Apache with mod_dav (WebDAV) or some other content
management system with a Web API. Or FTP for that matter.

AHS
 
L

Lew

Angel said:
I have problem to create a file in remote server, I got exception when
I create a file in remote server. Maybe I couldn't do in the following
way? When I tested this code to write the file in the same server, it
is fine. I already give the write permission in the images folder. I
don't know what went wrong, please advice [sic]. thanks

File file = new File("http://another_server/images/file1");
output = new BufferedWriter(new FileWriter(file));
output.write(text);

java.io.File does not take URLs in its constructor. It takes pathnames. The
URL you show is not a pathname.

The Javadocs are usually an excellent source of information.
<http://java.sun.com/javase/6/docs/api/java/io/File.html#File(java.lang.String)>

In order to write to an "http:" protocol resource, you must POST an HTTP
request to that resource, using the appropriate URL target, and the server
there must accept the request and enact it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top