A mutable sequence of characters. This class provides an API compatible with {@code StringBuffer}, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for {@code StringBuffer} in places where the string buffer was being used by a single thread (as is generally the case). Where possible,it is recommended that this class be used in preference to {@code StringBuffer} as it will be faster under most implementations. Unless otherwise noted, passing a {@code null} argument to a constructor or method in this class will cause a {@link NullPointerException} to be thrown.
/** * readObject is called to restore the state of the StringBuffer from * a stream. */ privatesynchronizedvoidwriteObject(java.io.ObjectOutputStream s) throws java.io.IOException { java.io.ObjectOutputStream.PutFieldfields= s.putFields(); fields.put("value", value); fields.put("count", count); fields.put("shared", false); s.writeFields(); }
/** * readObject is called to restore the state of the StringBuffer from * a stream. */ privatevoidreadObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { java.io.ObjectInputStream.GetFieldfields= s.readFields(); value = (char[])fields.get("value", null); count = fields.get("count", 0); } }