Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > problem to create a new file in remote server

Reply
Thread Tools

problem to create a new file in remote server

 
 
Angel Lowelle
Guest
Posts: n/a
 
      02-22-2009
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);
 
Reply With Quote
 
 
 
 
Arved Sandstrom
Guest
Posts: n/a
 
      02-22-2009
On Sat, 21 Feb 2009 16:39:47 -0800, Angel Lowelle wrote:

> 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
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      02-22-2009
Angel Lowelle wrote:
> 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.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WMI remote call in python script to create process on remote windowscomputer davidj411 Python 7 10-08-2009 08:58 AM
Remote.pm (File::Remote) problem Dayton Jones Perl Misc 9 03-03-2006 01:12 AM
Access to create file on remote server denied =?Utf-8?B?VmljdG9y?= ASP .Net 1 08-16-2005 09:22 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Need to create a multi-threaded component that streams file from remote server to asp.net dotnetnewbie ASP .Net Web Services 1 02-26-2004 09:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57