publicclass Ser { publicstaticvoid main(String[] args) throws Exception {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(Collections.EMPTY_SET);
out.flush();
ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(bos.toByteArray()));
if (!Collections.EMPTY_SET.equals(in.readObject())) thrownew RuntimeException("empty set Ser/Deser failure.");
} catch (Exception e) { thrownew RuntimeException("Failed to serialize empty set:" + e);
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(Collections.EMPTY_LIST);
out.flush();
ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(bos.toByteArray()));
if (!Collections.EMPTY_LIST.equals(in.readObject())) thrownew RuntimeException("empty list Ser/Deser failure.");
} catch (Exception e) { thrownew RuntimeException("Failed to serialize empty list:" + e);
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
Set gumby = Collections.singleton("gumby");
out.writeObject(gumby);
out.flush();
ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(bos.toByteArray()));
if (!gumby.equals(in.readObject())) thrownew RuntimeException("Singleton Ser/Deser failure.");
} catch (Exception e) { thrownew RuntimeException("Failed to serialize singleton:" + e);
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
List gumbies = Collections.nCopies(50, "gumby");
out.writeObject(gumbies);
out.flush();
ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(bos.toByteArray()));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.