private static byte[] serializePropertiesToByteArray(Properties p) throws IOException {
  ByteArrayOutputStream out=new ByteArrayOutputStream(4096);
  Properties props=new Properties();
  Set<String> keyset=p.stringPropertyNames();
  for (  String key : keyset) {
    String value=p.getProperty(key);
    props.put(key,value);
  }
  props.store(out,null);
  return out.toByteArray();
}

private static byte [ ] serializePropertiesToByteArray ( Properties p ) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream ( 4096 ) ; Properties props = new Properties ( ) ; Set < String > keyset = p . stringPropertyNames ( ) ; for ( String key : keyset ) { String value = p . getProperty ( key ) ; props . put ( key , value ) ; } props . store ( out , null ) ; return out . toByteArray ( ) ; }
write the given properties list to a byte array and return it . properties with a key or value that is not a string is filtered out . the stream written to the byte array is iso 8859 - 1 encoded .
