Code example for CharsetDecoder

Methods: decodeonMalformedInput

   * @param conf The configuration to do the setting on. 
  private static void setBinaryConfSetting(String isValueBinaryEncodedSetting,
      String potentiallyEncodedSetting, byte[] data, Configuration conf) {
    CharsetDecoder decoder = UTF_8.newDecoder();
    try { 
      CharBuffer colFamString = decoder.decode(ByteBuffer.wrap(data));
      conf.setBoolean(isValueBinaryEncodedSetting, false);
      conf.set(potentiallyEncodedSetting, colFamString.toString());
    } catch (CharacterCodingException e) {
      conf.setBoolean(isValueBinaryEncodedSetting, true);
      conf.set(potentiallyEncodedSetting, new String(Base64.encodeBase64(data),
   * Get the contents of a key that might be binary. 
   * @param isBinarySettingKey Tells us weather or not the field is binary.