Java Utililty Methods Collection Serialize

List of utility methods to do Collection Serialize

Description

The list of methods to do Collection Serialize are organized into topic(s).

Method

byte[]serialize(List features)
Serialize to byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(bos);
out.writeObject(features);
byte[] result = bos.toByteArray();
out.close();
return result;
voidserialize(Map> in, OutputStream out)
serialize
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out))) {
    for (Map.Entry<String, Map<String, String>> section : in.entrySet()) {
        bw.write("[");
        bw.write(section.getKey());
        bw.write("]");
        bw.newLine();
        for (Map.Entry<String, String> kv : section.getValue().entrySet()) {
            if (kv.getValue() != null) {
...
voidserializeMap(Map map, File file)
Serialize a Map.
try {
    ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(file));
    os.writeObject(map);
    os.close();
} catch (Exception e) {
    e.printStackTrace();
byte[]serializeSet(Set set)
serialize Set
if (set.isEmpty()) {
    return null;
ObjectOutputStream oos = null;
ByteArrayOutputStream baos = null;
byte[] bytes = null;
try {
    baos = new ByteArrayOutputStream();
...
byte[]SerializeVectorOfInts(Vector m)
Serialize Vector Of Ints
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bos);
try {
    out.writeInt(m.size());
    for (int i = 0; i < m.size(); i++) {
        out.writeInt(m.get(i));
} catch (Exception e) {
...