Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.programmer > #5125
| From | Lothar Kimmeringer <news200709@kimmeringer.de> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: File object and serialization - information is lost |
| Date | 2011-06-08 20:18 +0200 |
| Organization | Organization?! Only chaos here! |
| Message-ID | <yi8ydsfv62zw.dlg@kimmeringer.de> (permalink) |
| References | <isoda3$n3n$1@news.albasani.net> |
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 | Next — Previous in thread | Next in thread | Find similar
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