![]() |
|
|
|||||||
![]() |
Java - problem to create a new file in remote server |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |