problem to create a new file in remote server

Discussion in 'Java' started by Angel Lowelle, Feb 22, 2009.

  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, Feb 22, 2009
    #1
    1. Advertising

  2. 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, Feb 22, 2009
    #2
    1. Advertising

  3. Angel Lowelle

    Lew Guest

    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, Feb 22, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VmljdG9y?=

    Access to create file on remote server denied

    =?Utf-8?B?VmljdG9y?=, Aug 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    486
    =?Utf-8?B?RnJhbsOnb2lzIExlbWFpcmU=?=
    Aug 16, 2005
  2. davidj411
    Replies:
    7
    Views:
    3,223
    Tim Golden
    Oct 8, 2009
  3. dotnetnewbie
    Replies:
    1
    Views:
    130
  4. Dayton Jones

    Remote.pm (File::Remote) problem

    Dayton Jones, Mar 1, 2006, in forum: Perl Misc
    Replies:
    9
    Views:
    171
    Dayton Jones
    Mar 3, 2006
  5. Replies:
    2
    Views:
    406
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page