WProperties extends Properties { public void putByteArrayProperty(String key, byte[] value) { if (isKeyValid(key)) { try { String val = StringUtil.EMPTY_STRING; if(value != null && value.length > 0) { val = new String(Base64.getEncoder().encode(GzipManager.gzipCompressToByte(value))); } this.put(key, val); } catch (IOException e) { LOGGER.error("Set byte property", e); } } } WProperties(); @Override synchronized Object setProperty(String key, String value); @Override String getProperty(String key); void resetProperty(String key, String defaultValue); void resetServiceProperty(String key, String defaultValue); void putIntProperty(String key, int value); int getIntProperty(String key, int def); void putLongProperty(String key, long value); long getLongProperty(String key, long def); void putBooleanProperty(String key, boolean value); boolean getBooleanProperty(String key, boolean def); void putFloatProperty(String key, float value); float getFloatProperty(String key, float def); void putDoubleProperty(String key, double value); double getDoubleProperty(String key, double def); Color getColorProperty(String key); void putColorProperty(String key, Color color); void putByteArrayProperty(String key, byte[] value); byte[] getByteArrayProperty(String key, byte[] def); static String color2Hexadecimal(Color c, boolean alpha); static Color hexadecimal2Color(String hexColor); static void setProperty(WProperties properties, String key, Preferences prefNode, String defaultValue);  }
@Test public void testPutByteArrayProperty() { WProperties prop = new WProperties(); byte[] data = new byte[] { 0, 3, 43, 32, 34, 54, 127, 0, (byte) 255 }; prop.putByteArrayProperty("byte", data); Assert.assertArrayEquals("different byte data", data, prop.getByteArrayProperty("byte", null)); prop.putByteArrayProperty("byte", null); Assert.assertArrayEquals("different byte data", null, prop.getByteArrayProperty("byte", null)); prop.putByteArrayProperty("byte", new byte[] {}); Assert.assertArrayEquals("different byte data", null, prop.getByteArrayProperty("byte", null)); }