Java Object Serialize and Deserialize deserializeProperties(byte[] bytes)

Here you can find the source of deserializeProperties(byte[] bytes)

Description

Tries to deserialize given bytes array to Properties instance

License

Open Source License

Parameter

Parameter Description
bytes bytes array that is supposed to contain serialized properties data

Return

Properties instance populated with data deserialized from given bytes array, or empty if deserialization failed

Declaration

public static Properties deserializeProperties(byte[] bytes) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.util.Properties;

public class Main {
    /**//www . j av  a2 s.c  om
     * Tries to deserialize given bytes array to Properties instance
     * 
     * @param bytes bytes array that is supposed to contain serialized properties data
     * @return Properties instance populated with data deserialized from given bytes array, 
     *         or empty if deserialization failed
     */
    public static Properties deserializeProperties(byte[] bytes) {
        Properties properties = new Properties();
        if (bytes != null) {
            try {
                ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                properties.load(bais);
                bais.close();
            } catch (IOException e) {
            }
        }
        return properties;
    }
}

Related

  1. deSerializeObject(byte[] base64SerializedObject)
  2. deserializeObject(String dir)
  3. deSerializeObject(String str, Class cls)
  4. deserializeObjectFromByteArray(byte[] data)
  5. deserializeObjectFromByteArray(byte[] theSerializedVersion)
  6. deserializeRaw(byte[] array)
  7. deserializeSafe(byte[] buf, T obj)
  8. deserializeShort(byte[] inbuf, int offset)
  9. deserializeStream(final String witness)