src/share/classes/java/io/File.java

Print this page




1989      * Returns the pathname string of this abstract pathname.  This is just the
1990      * string returned by the <code>{@link #getPath}</code> method.
1991      *
1992      * @return  The string form of this abstract pathname
1993      */
1994     public String toString() {
1995         return getPath();
1996     }
1997 
1998     /**
1999      * WriteObject is called to save this filename.
2000      * The separator character is saved also so it can be replaced
2001      * in case the path is reconstituted on a different host type.
2002      * <p>
2003      * @serialData  Default fields followed by separator character.
2004      */
2005     private synchronized void writeObject(java.io.ObjectOutputStream s)
2006         throws IOException
2007     {
2008         s.defaultWriteObject();
2009         s.writeChar(this.separatorChar); // Add the separator character
2010     }
2011 
2012     /**
2013      * readObject is called to restore this filename.
2014      * The original separator character is read.  If it is different
2015      * than the separator character on this system, then the old separator
2016      * is replaced by the local separator.
2017      */
2018     private synchronized void readObject(java.io.ObjectInputStream s)
2019          throws IOException, ClassNotFoundException
2020     {
2021         ObjectInputStream.GetField fields = s.readFields();
2022         String pathField = (String)fields.get("path", null);
2023         char sep = s.readChar(); // read the previous separator char
2024         if (sep != separatorChar)
2025             pathField = pathField.replace(sep, separatorChar);
2026         this.path = fs.normalize(pathField);
2027         this.prefixLength = fs.prefixLength(this.path);
2028     }
2029 




1989      * Returns the pathname string of this abstract pathname.  This is just the
1990      * string returned by the <code>{@link #getPath}</code> method.
1991      *
1992      * @return  The string form of this abstract pathname
1993      */
1994     public String toString() {
1995         return getPath();
1996     }
1997 
1998     /**
1999      * WriteObject is called to save this filename.
2000      * The separator character is saved also so it can be replaced
2001      * in case the path is reconstituted on a different host type.
2002      * <p>
2003      * @serialData  Default fields followed by separator character.
2004      */
2005     private synchronized void writeObject(java.io.ObjectOutputStream s)
2006         throws IOException
2007     {
2008         s.defaultWriteObject();
2009         s.writeChar(separatorChar); // Add the separator character
2010     }
2011 
2012     /**
2013      * readObject is called to restore this filename.
2014      * The original separator character is read.  If it is different
2015      * than the separator character on this system, then the old separator
2016      * is replaced by the local separator.
2017      */
2018     private synchronized void readObject(java.io.ObjectInputStream s)
2019          throws IOException, ClassNotFoundException
2020     {
2021         ObjectInputStream.GetField fields = s.readFields();
2022         String pathField = (String)fields.get("path", null);
2023         char sep = s.readChar(); // read the previous separator char
2024         if (sep != separatorChar)
2025             pathField = pathField.replace(sep, separatorChar);
2026         this.path = fs.normalize(pathField);
2027         this.prefixLength = fs.prefixLength(this.path);
2028     }
2029