/** * Decode an input array of chars into an output array of bytes. This method is * more inefficient than the 5-parameter version below since a new byte output * array is allocated and returned with each call. * @param inarray An character array holding the data to be converted from * Base64 to bytes. * @param instart The start position of the character data to be converted. * @param inlength The length of the character data to be converted. * @return A byte array holding the decoded bytes. */ // for example, (11 + 1) * 3 = 36 -> 9?? public static byte[] decode(char[] inarray, int instart, int inlength) { // 3 6 9 12 15 18 21 24 // 1->1 2->2 3->3 4->3 5->4 6->5 7->6 8->6 byte[] sufficientbuffer = new byte[((inlength + 1)* 3) / 4]; decode(inarray, instart, inlength, sufficientbuffer, 0); return sufficientbuffer; }
public Object parse(String toparse) { // all this will go away with the new parser int length = toparse.length(); System.out.println("Parsing randomaccesspointer with length " + length); char[] unnecessarybuffer = new char[length]; toparse.getChars(0, length, unnecessarybuffer, 0); byte[] bytes = CharToByteBase64.decode(unnecessarybuffer, 0, length); ByteWrap wrap = new ByteWrap(bytes, bytes.length - 8, 8); return new RandomAccessPointer(wrap.read_at8(0)); }