OrderPreservingBase64 { public static byte[] decode(byte[] data) { return decode(data, 0, data.length); }  static byte[] encode(byte[] data); static byte[] encode(byte[] data, int offset, int len); static void encodeToStream(byte[] data, OutputStream out); static void encodeToStream(OutputStream out, byte[] data, int offset, int datalen); static void encodeToWriter(byte[] data, Writer out); static void encodeToWriter(Writer out, byte[] data, int offset, int datalen); static byte[] decode(byte[] data); static byte[] decode(byte[] data, int offset, int len);  }
@Test public void testDecode() { byte[] data = "zk".getBytes(); byte[] decoded = OrderPreservingBase64.decode(data); Assert.assertEquals(1, decoded.length); Assert.assertEquals(-1, decoded[0]); data = "zzw".getBytes(); decoded = OrderPreservingBase64.decode(data); Assert.assertEquals(2, decoded.length); Assert.assertEquals(-1, decoded[0]); Assert.assertEquals(-1, decoded[1]); data = "zzzz".getBytes(); decoded = OrderPreservingBase64.decode(data); Assert.assertEquals(3, decoded.length); Assert.assertEquals(-1, decoded[0]); Assert.assertEquals(-1, decoded[1]); Assert.assertEquals(-1, decoded[2]); data = "zzzzzk".getBytes(); decoded = OrderPreservingBase64.decode(data); Assert.assertEquals(4, decoded.length); Assert.assertEquals(-1, decoded[0]); Assert.assertEquals(-1, decoded[1]); Assert.assertEquals(-1, decoded[2]); Assert.assertEquals(-1, decoded[3]); }