Send File object thru ObjectOutputStream ObjectInputStream


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Send File object thru ObjectOutputStream ObjectInputStream

  1. #1
    Lim Wing Hoe Guest

    Send File object thru ObjectOutputStream ObjectInputStream

    Is this possible to send a File Object using such stream?
    E.g. writeObject(myFile)


    --



    Best Regards,
    Wing Hoe
    ---------------------------------------------------------------
    Email: winghoe@hotmail.com
    ICQ: 2213281
    www: http://pwp.maxis.net.my/winghoe
    Job Seeking Status : Active
    Availability : May 2001 (after degree course finish)
    ---------------------------------------------------------------





  2. #2
    Paul Clapham Guest

    Re: Send File object thru ObjectOutputStream ObjectInputStream

    I don't know the answer to that, but the way to find out is to look in the
    Java documentation for the File class. The answer is Yes if and only if it
    implements Serializable.

    PC2

    Lim Wing Hoe <winghoe@hotmail.com> wrote in message
    news:3a462a19@news.devx.com...
    > Is this possible to send a File Object using such stream?
    > E.g. writeObject(myFile)






  3. #3
    Lim Wing Hoe Guest

    Re: Send File object thru ObjectOutputStream ObjectInputStream

    Hi guys,

    I did some research on my own. Must say Sun's Discussion Forum is really
    packed!
    What I found out is, if I create a File object, and send the object thru the
    object streams, the ACTUAL content of the file is not sent. Rather, it's
    something like a reference or object thingy only.

    Also, I found some bizzare problems when I send the File objects from the
    server to the client.

    What happens is, some of the File objects lost the ability to determine
    whether it's a file or a directory using isDirectory() / isFile() methods.
    Thus, it caused some irregularities when I use JList and ListCellRenderer to
    place the folder/file icon next to the text. This include the path thingy
    that got lost with some of the File objects.

    Everything works file in the server side. Only when the File objects are
    sent to the client, such problem occurs.

    What I believe to have happen is, the path for the File objects will be
    invalid, once it has been sent to the client. You know, if you refer to a
    file in a webserver, you should use something like www.sun.com/myfile.txt
    kind of convention? The File objects that were sent from the server may
    still retain something like /pub/myFile.txt.

    The only way I can get the file lists thru to the client is get the name
    representation of the file object using getName() method, save the names
    into Vector, send it to the client, show it as files with the file icon.

    If I want to send a file (the content that is) from the client to the server
    or vice versa, it has been some recommendation to use input/output streams
    to send the file as bytes.

    Oh yeah, hope it's not too late to say merry christmas to you all...

    This file transfer project has been bugging me for the past few days.

    --



    Best Regards,
    Wing Hoe
    ---------------------------------------------------------------
    Email: winghoe@hotmail.com
    ICQ: 2213281
    www: http://pwp.maxis.net.my/winghoe
    Job Seeking Status : Active
    Availability : May 2001 (after degree course finish)
    ---------------------------------------------------------------


    "Paul Clapham" <pclapham@core-mark.com> wrote in message
    news:3a48f7b8@news.devx.com...
    > I don't know the answer to that, but the way to find out is to look in the
    > Java documentation for the File class. The answer is Yes if and only if

    it
    > implements Serializable.
    >
    > PC2
    >
    > Lim Wing Hoe <winghoe@hotmail.com> wrote in message
    > news:3a462a19@news.devx.com...
    > > Is this possible to send a File Object using such stream?
    > > E.g. writeObject(myFile)

    >
    >
    >
    >




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