Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #5125

Re: File object and serialization - information is lost

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!news.internetdienste.de!news.tu-darmstadt.de!news.belwue.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail
From Lothar Kimmeringer <news200709@kimmeringer.de>
Newsgroups comp.lang.java.programmer
Subject Re: File object and serialization - information is lost
Date Wed, 8 Jun 2011 20:18:36 +0200
Organization Organization?! Only chaos here!
Lines 52
Message-ID <yi8ydsfv62zw.dlg@kimmeringer.de> (permalink)
References <isoda3$n3n$1@news.albasani.net>
Reply-To news@kimmeringer.de
NNTP-Posting-Host mnch-4d044605.pool.mediaways.net
Mime-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Trace online.de 1307557116 32091 77.4.70.5 (8 Jun 2011 18:18:36 GMT)
X-Complaints-To abuse@einsundeins.com
NNTP-Posting-Date Wed, 8 Jun 2011 18:18:36 +0000 (UTC)
User-Agent 40tude_Dialog/2.0.15.1de
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5125

Show key headers only | View raw


Sebastian wrote:

> I seem to misunderstand a thing about java.io.File. I wanted to use
> the File object to transport information files existing in one place
> (basically, a directory listing) to another place.
> 
> The API says File serves as an abstract representation of a file, and
> that it implements Serializable.

That should say it all. It only represents a file, but nothing more.

> However, after Serialization/Deserialization (in another JVM) the
> methods lastModified() and length() return 0. This is not what I
> expected.

Have a look into the source of java.io.File. The only member are
(copied from JDK 1.6.0):

    /**
     * This abstract pathname's normalized pathname string.  A normalized
     * pathname string uses the default name-separator character and does not
     * contain any duplicate or redundant separators.
     *
     * @serial
     */
    private String path;

    /**
     * The length of this abstract pathname's prefix, or zero if it has no
     * prefix.
     */
    private transient int prefixLength;

Only one value being serialized, the path. This doesn't come as
a surprise since it's only representing a file in an abstract
way and that's the path (including the filename).

> Is there a standard object to transport this information, or do I have
> to define my own?

When I was in need for something like this (for a GWT-application)
I implemented it myself because it was faster than searching the
Internet for something that contains all I need.


Regards, Lothar
-- 
Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
               PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                 questions!

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

File object and serialization - information is lost Sebastian <sebastian@undisclosed.invalid> - 2011-06-08 19:59 +0200
  Re: File object and serialization - information is lost Lothar Kimmeringer <news200709@kimmeringer.de> - 2011-06-08 20:18 +0200
    Re: File object and serialization - information is lost Sebastian <sebastian@undisclosed.invalid> - 2011-06-08 20:35 +0200

csiph-web