Существуют официальные (не sun.misc
) реализации на Java, но это не то, где кто-либо предполагает.
java.util.prefs.AbstractPreferences
это тот, который имеет необходимые методы для этого. Вы должны переопределить метод put
.
И еще один, который гораздо проще в использовании:
javax.xml.bind.DatatypeConverter
у него есть 2 метода интереса:
разъяснение природы base64 AbstractPreferences:
java.util.prefs.Preferences
/**
* Associates a string representing the specified byte array with the
* specified key in this preference node. The associated string is
* the <i>Base64</i> encoding of the byte array, as defined in RFC 2045, Section 6.8,
* with one minor change: the string will consist solely of characters
* from the <i>Base64 Alphabet</i>; it will not contain any newline
* characters. Note that the maximum length of the byte array is limited
* to three quarters of MAX_VALUE_LENGTH so that the length
* of the Base64 encoded String does not exceed MAX_VALUE_LENGTH.
* This method is intended for use in conjunction with
* {@link #getByteArray}.
*/
public abstract void putByteArray(String key, byte[] value);