/** * decode the Hex encoded String data - whitespace will be ignored. * * @return a byte array representing the decoded data. */ public static byte[] decode( String data) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { encoder.decode(data, bOut); } catch (Exception e) { throw new DecoderException("exception decoding Hex string: " + e.getMessage(), e); } return bOut.toByteArray(); }
throw new IOException(e.getMessage());
/** * decode the URL safe base 64 encoded String data - whitespace will be ignored. * * @return a byte array representing the decoded data. */ public static byte[] decode( String data) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { encoder.decode(data, bOut); } catch (Exception e) { throw new DecoderException("exception decoding URL safe base64 string: " + e.getMessage(), e); } return bOut.toByteArray(); }
/** * decode the Hex encoded input data. It is assumed the input data is valid. * * @return a byte array representing the decoded data. */ public static byte[] decode( byte[] data) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { encoder.decode(data, 0, data.length, bOut); } catch (Exception e) { throw new DecoderException("exception decoding Hex data: " + e.getMessage(), e); } return bOut.toByteArray(); }
/** * Decode the URL safe base 64 encoded input data - white space will be ignored. * * @return a byte array representing the decoded data. */ public static byte[] decode( byte[] data) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { encoder.decode(data, 0, data.length, bOut); } catch (Exception e) { throw new DecoderException("exception decoding URL safe base64 string: " + e.getMessage(), e); } return bOut.toByteArray(); }
/** * Decode to an output stream; * * @param base64Data The source data. * @param start Start position. * @param length the length. * @param out The output stream to write to. */ public static int decode(byte[] base64Data, int start, int length, OutputStream out) { try { return encoder.decode(base64Data, start, length, out); } catch (Exception e) { throw new DecoderException("unable to decode base64 data: " + e.getMessage(), e); } } }
/** * decode the base 64 encoded input data. It is assumed the input data is valid. * * @return a byte array representing the decoded data. */ public static byte[] decode( byte[] data) { int len = data.length / 4 * 3; ByteArrayOutputStream bOut = new ByteArrayOutputStream(len); try { encoder.decode(data, 0, data.length, bOut); } catch (Exception e) { throw new DecoderException("unable to decode base64 data: " + e.getMessage(), e); } return bOut.toByteArray(); }
/** * decode the base 64 encoded String data - whitespace will be ignored. * * @return a byte array representing the decoded data. */ public static byte[] decode( String data) { int len = data.length() / 4 * 3; ByteArrayOutputStream bOut = new ByteArrayOutputStream(len); try { encoder.decode(data, bOut); } catch (Exception e) { throw new DecoderException("unable to decode base64 string: " + e.getMessage(), e); } return bOut.toByteArray(); }