DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Writing unique files to a server

  1. #1
    Chad Guest

    Writing unique files to a server


    How do I write a file to a server using Java? To make matters more difficult,
    I want the file name to be unique and I plan on doing this with the random
    number generator. So....where is the "Save As?"

    The file I plan to write is actually a concatenated comma delimitted string
    of: date, time, answer -- where answer is the result from a list box selection.

    Chad

  2. #2
    Paul Clapham Guest

    Re: Writing unique files to a server

    When you say "to a server", should we assume that you are asking how an
    applet can do this? If so, then the answer is that it depends on the
    server. If it is running an FTP server, then your applet could implement an
    FTP client to write the file. If it is running only an HTTP server (your
    typical web server), then there's an HTTP method called "PUT" that I think
    is supposed to be for this, but I've never seen it implemented and don't
    know how it works.

    If you can run a servlet (or other form of CGI) on the server, you may have
    more luck doing this. Then you just have to learn how to send the data to
    the servlet and let it create the file on the server. There's a method
    called File.createTempFile that can create randomly-named files for you.

    PC2

    Chad <chad.hullender@aa.com> wrote in message
    news:39de1ed0$1@news.devx.com...
    >
    > How do I write a file to a server using Java? To make matters more

    difficult,
    > I want the file name to be unique and I plan on doing this with the random
    > number generator. So....where is the "Save As?"
    >
    > The file I plan to write is actually a concatenated comma delimitted

    string
    > of: date, time, answer -- where answer is the result from a list box

    selection.
    >
    > Chad




  3. #3
    chad hullender Guest

    Re: Writing unique files to a server


    Thanks Paul..

    Actually, I was meaning to be more simple than that. Sorry about the confustion.

    I have a variable, let's say "answer" that is a combination of the results
    of a date/time stamp AND the selection from a multiple menu box. This variable
    may very well look like "10082000,1455,2".

    That variable needs to be stored in a file name that is unique and randomly
    generated. i.e. [random number].txt

    That file will then be "saved as" or "copied to" a Novell networked fileserver.
    I forgot that when I mentioned server it could mean a whole host of things.


    So, simply stated I am seeking to 1) make a string a file with a unique name
    and 2) copy that file (or write it) to a network server just like you would
    copy a file using Windows Explorer -- no URL, just a mapped drive letter.

    Thank you!

    Chad
    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >When you say "to a server", should we assume that you are asking how an
    >applet can do this? If so, then the answer is that it depends on the
    >server. If it is running an FTP server, then your applet could implement

    an
    >FTP client to write the file. If it is running only an HTTP server (your
    >typical web server), then there's an HTTP method called "PUT" that I think
    >is supposed to be for this, but I've never seen it implemented and don't
    >know how it works.
    >
    >If you can run a servlet (or other form of CGI) on the server, you may have
    >more luck doing this. Then you just have to learn how to send the data

    to
    >the servlet and let it create the file on the server. There's a method
    >called File.createTempFile that can create randomly-named files for you.
    >
    >PC2
    >
    >Chad <chad.hullender@aa.com> wrote in message
    >news:39de1ed0$1@news.devx.com...
    >>
    >> How do I write a file to a server using Java? To make matters more

    >difficult,
    >> I want the file name to be unique and I plan on doing this with the random
    >> number generator. So....where is the "Save As?"
    >>
    >> The file I plan to write is actually a concatenated comma delimitted

    >string
    >> of: date, time, answer -- where answer is the result from a list box

    >selection.
    >>
    >> Chad

    >
    >



  4. #4
    Paul Clapham Guest

    Re: Writing unique files to a server

    Then it sounds like File.createTempFile is what you need. I don't see why
    the fact that the file is going to be on a network drive is an issue, just
    use the version of the method that creates the new file in a specified
    directory. Or are you asking how to write text to a file?

    PC2

    chad hullender <amrdms1@aol.com> wrote in message
    news:39e0cf71$1@news.devx.com...
    >
    > Thanks Paul..
    >
    > Actually, I was meaning to be more simple than that. Sorry about the

    confustion.
    >
    > I have a variable, let's say "answer" that is a combination of the results
    > of a date/time stamp AND the selection from a multiple menu box. This

    variable
    > may very well look like "10082000,1455,2".
    >
    > That variable needs to be stored in a file name that is unique and

    randomly
    > generated. i.e. [random number].txt
    >
    > That file will then be "saved as" or "copied to" a Novell networked

    fileserver.
    > I forgot that when I mentioned server it could mean a whole host of

    things.
    >
    >
    > So, simply stated I am seeking to 1) make a string a file with a unique

    name
    > and 2) copy that file (or write it) to a network server just like you

    would
    > copy a file using Windows Explorer -- no URL, just a mapped drive letter.
    >
    > Thank you!
    >
    > Chad





  5. #5
    th lim Guest

    Re: Writing unique files to a server


    2 possible solutions (or more??) are: -
    1. like earlier said, use a servlet to get the stream of data and write it
    to a file.
    2. get a SMB java-type library to enable you to read/write to any Windows
    as in Explorer. There is one called JLan Pro (www.starlasoft.com) and it
    is not a freeware.

    /lim/

    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >Then it sounds like File.createTempFile is what you need. I don't see why
    >the fact that the file is going to be on a network drive is an issue, just
    >use the version of the method that creates the new file in a specified
    >directory. Or are you asking how to write text to a file?
    >
    >PC2
    >
    >chad hullender <amrdms1@aol.com> wrote in message
    >news:39e0cf71$1@news.devx.com...
    >>
    >> Thanks Paul..
    >>
    >> Actually, I was meaning to be more simple than that. Sorry about the

    >confustion.
    >>
    >> I have a variable, let's say "answer" that is a combination of the results
    >> of a date/time stamp AND the selection from a multiple menu box. This

    >variable
    >> may very well look like "10082000,1455,2".
    >>
    >> That variable needs to be stored in a file name that is unique and

    >randomly
    >> generated. i.e. [random number].txt
    >>
    >> That file will then be "saved as" or "copied to" a Novell networked

    >fileserver.
    >> I forgot that when I mentioned server it could mean a whole host of

    >things.
    >>
    >>
    >> So, simply stated I am seeking to 1) make a string a file with a unique

    >name
    >> and 2) copy that file (or write it) to a network server just like you

    >would
    >> copy a file using Windows Explorer -- no URL, just a mapped drive letter.
    >>
    >> Thank you!
    >>
    >> Chad

    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center