Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No need to have the redundant array + all the logic around + use the given methods to manipulate the buffer + utf is better for strings and avoid the casts + synchronization (but it is not thread safe anyway) : </p> <pre><code>private synchronized void writeObject(final ObjectOutputStream out) throws IOException { out.writeUTF(title); out.writeUTF(url_friendly_name); out.writeUTF(creator_name); out.writeUTF(version); out.writeUTF(package_name); out.writeUTF(contact_website); out.writeInt(popularity); out.writeUTF(inconditional_redirect == null ? "" : inconditional_redirect); out.writeUTF(custom_description == null ? "" : custom_description); out.writeInt(icon.getRowBytes()); out.writeInt(icon.getHeight()); out.writeInt(icon.getWidth()); out.writeInt(icon.getConfig().ordinal()); final int bmSize = icon.getRowBytes() * icon.getHeight(); if (dst == null || bmSize &gt; dst.capacity()) { dst = ByteBuffer.allocate(bmSize); } dst.rewind(); icon.copyPixelsToBuffer(dst); dst.flip(); out.write(dst.array(), 0, bmSize); } private synchronized void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { title = in.readUTF(); url_friendly_name = in.readUTF(); creator_name = in.readUTF(); version = in.readUTF(); package_name = in.readUTF(); contact_website = in.readUTF(); popularity = in.readInt(); inconditional_redirect = in.readUTF(); custom_description = in.readUTF(); final int nbRowBytes = in.readInt(); final int height = in.readInt(); final int width = in.readInt(); final Bitmap.Config config = Bitmap.Config.values()[in.readInt()]; final int bmSize = nbRowBytes * height; if (dst == null || bmSize &gt; dst.capacity()) { dst = ByteBuffer.allocate(bmSize); } dst.rewind(); in.read(dst.array(), 0, bmSize); icon = Bitmap.createBitmap(width, height, config); icon.copyPixelsFromBuffer(dst); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload