Example usage for org.apache.commons.codec DecoderException printStackTrace

List of usage examples for org.apache.commons.codec DecoderException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.codec DecoderException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:models.logic.CipherDecipher.java

public static SecretKey stringToKey(String keyString) {
    byte[] encoded;
    try {//  ww  w  .j av  a 2 s  .  c  o m
        encoded = decodeHex(keyString.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }
    return new SecretKeySpec(encoded, "AES");
}

From source file:models.logic.CipherDecipher.java

public static SecretKey fileToKey(String keyPath) throws IOException, DecoderException {
    File keyFile = new File(keyPath);
    String data = new String(readFileToByteArray(keyFile));
    byte[] encoded;
    try {//from w ww . j a va 2 s .c  om
        encoded = decodeHex(data.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }
    return new SecretKeySpec(encoded, "AES");
}

From source file:com.net.wx.util.Encodes.java

/**
 * Hex?./* ww  w . j a  v  a  2 s. c o m*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.mastercard.mobile_api.utils.Tlv.java

/**
 * Creates a Tlv byte array from a tag and a value. Length is calculated.
 * Data Input is in Hex String//from  w  ww  .  j a  va  2  s  .co m
 *
 * @param tag   the Tlv tag (HEX String)
 * @param value the Tlv value (HEX String)
 * @return the Tlv byte array (HEX String)
 */
public static String create(String tag, String value) {
    byte[] bValue = new byte[0];
    try {
        bValue = Hex.decodeHex(value.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
    }
    byte[] bLength = lengthBytes(bValue);
    String length = new String(Hex.encodeHex(bLength));
    return (tag + length + value).toUpperCase();
}

From source file:ezbake.services.graph.archive.TransactionIdGenerator.java

private static int getServerID() {
    byte[] serverId = null;

    try {// w w  w  .  ja  v a2 s.  c o  m
        serverId = getOpenShiftGearUUID();
    } catch (Exception e) {
        logger.info("Not on an OPENSHIFT machine, acquiring MOCK UUID");
        try {
            serverId = getDefaultServerId();
        } catch (DecoderException e1) {
            e1.printStackTrace();
            logger.info("Error acquiring valid UUID");
        }
    }

    Preconditions.checkNotNull(serverId);
    return ByteBuffer.wrap(serverId).getInt();
}

From source file:com.weblyzard.lib.string.nilsimsa.Nilsimsa.java

private static byte[] _getByteArray(String hexString) {
    try {/*from   ww w.  j  a v a2  s.  co m*/
        return Hex.decodeHex(hexString.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.nxp.ltsm.ltsmclient.tools.VCDescriptionFile.java

public static byte[] createF8Vc(String appName, short vcEntry, byte[] mfdfaid, byte[] cltecap) {
    String TAG = "VCDescriptionFile:createVC";
    Log.i(TAG, "Enter");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] apkId = null;
    try {/* w w w .ja va 2s.  co  m*/
        apkId = Hex.decodeHex(appName.toCharArray());
    } catch (DecoderException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return null;
    }
    try {
        out.write(TLV.createTLV(0x4F, apkId));
        out.write(TLV.createTLV(0x40, new byte[] { (byte) (vcEntry >> 8), (byte) (vcEntry) }));
        out.write(TLV.createTLV(0xF8, mfdfaid));
        out.write(TLV.createTLV(0xE2, cltecap));
        return TLV.createTLV(0x74, out.toByteArray());
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
        return null;
    }
}

From source file:com.netsteadfast.greenstep.util.SimpleUtils.java

public static String deHex(final String sourceValue) {
    String value = "";
    try {//from w  w  w .j  av  a  2  s.co m
        value = new String(org.apache.commons.codec.binary.Hex
                .decodeHex(SimpleUtils.getStr(sourceValue, "").toCharArray()));
    } catch (DecoderException e) {
        e.printStackTrace();
    }
    return value;
}

From source file:com.mnr.java.intellij.idea.plugin.base64helper.HexEncoderPopupItem.java

@Override
public String encodeDecode(String selectedText) {
    selectedText = Util.makeEvenHexDigit(selectedText);

    byte[] decodeHex;

    try {// w  w  w  .jav  a  2s .  c  o m
        decodeHex = Hex.decodeHex(selectedText.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }

    return Base64.encodeBase64String(decodeHex);
}

From source file:com.adavr.player.media.XVClient.java

@Override
public String getStreamURL(String url) throws ClientException {
    Map<String, String> flashVars = getFlashVars(url);
    if (flashVars == null) {
        return null;
    }// w ww. j ava  2  s . c  o  m
    String flvUrl = flashVars.get("flv_url");
    try {
        return new URLCodec().decode(flvUrl);
    } catch (DecoderException ex) {
        ex.printStackTrace();
        return null;
    }
}