Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - problem to create a new file in remote server

 
Thread Tools Search this Thread
Old 02-22-2009, 12:39 AM   #1
Default problem to create a new file in remote server


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);


Angel Lowelle
  Reply With Quote
Old 02-22-2009, 01:05 AM   #2
Arved Sandstrom
 
Posts: n/a
Default Re: problem to create a new file in remote server
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


Arved Sandstrom
  Reply With Quote
Old 02-22-2009, 01:13 AM   #3
Lew
 
Posts: n/a
Default Re: problem to create a new file in remote server
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


Lew
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help : The remote server returned an error: (401) Unauthorized adarsh.vishnoi Software 0 06-05-2008 01:21 PM
Computer Security aldrich.chappel.com.use@gmail.com A+ Certification 0 11-27-2007 02:11 AM
SQL Server 2005 Migration Assistant Autonumber problem. LarryWestMCSD MCTS 1 03-28-2007 02:08 AM
JVC remote control - weird problem Robb Scott DVD Video 0 08-17-2004 12:01 PM
Re: Need Ideas For A New Server, Long Post Gareth Church A+ Certification 2 07-27-2003 12:46 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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