Converts byte array to stream
byte[] data = ...
InputStream is = Bytes.asStream(data);
Converts stream to byte array
InputStream is = ...
byte[] data = Bytes.fromStream(is);
Transfer byte array to stream
byte[] data = ...
OutputStream os = ...
Bytes.toStream(data, os);
Transfer stream to stream
InputStream is = ...
OutputStream os = ...
int size = Bytes.transfer(is, os);
Simple base64 encoder
byte[] data = ...
String text = Base64.encode(data);
byte[] newdata = Base64.decode(text);
Simple bytes to text encoder baset on Base64 but uses different charset. It produce encoded text with only characters from given charset (no '=' padding)
byte[] charset = new char[] {'a', 'b', ..... 64 unique chars};
byte[] data = ...
Any64 encoder = Any64.instance(charset);
String text = encoder.encode(data);
byte[] newdata = encoder.decode(text);
If you are satisfied with Base64 charset and you want to replace only plus and slash characters. (Usually only those characters are problematic.)
byte[] data = ...
Any64 encoder = Any64.instance('?', '!');
String text = encoder.encode(data);
byte[] newdata = encoder.decode(text);
Simple Hex encoder
byte[] data = ...
String text = Hex.encode(data);
byte[] newdata = Hex.decode(text);
Simple unicode encoder
String data = ...
String text = Unicode.escape(data, false);
String newdata = Unicode.unescape(text);
Simple html escaping encoder
String data = ...
String text = Html.escapeSimple(data);
String newdata = Html.unescape(text);
Remove html tags from given text. (From "
foo
" generate "foo") String html = ...
String text = HtmlEraser.of(html).erase();