Example usage for java.io UnsupportedEncodingException getMessage

List of usage examples for java.io UnsupportedEncodingException getMessage

Introduction

In this page you can find the example usage for java.io UnsupportedEncodingException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:be.fedict.commons.eid.consumer.tlv.SpecialOrganisationConvertor.java

@Override
public SpecialOrganisation convert(final byte[] value) throws DataConvertorException {
    if (null == value) {
        return SpecialOrganisation.UNSPECIFIED;
    }/*from  w  ww  .j  av a2  s . c o m*/
    String key;
    try {
        key = new String(value, "UTF-8");
    } catch (final UnsupportedEncodingException uex) {
        throw new DataConvertorException("string error: " + uex.getMessage());
    }
    LOG.debug("key: \"" + key + "\"");
    final SpecialOrganisation specialOrganisation = SpecialOrganisation.toSpecialOrganisation(key);
    return specialOrganisation;
}

From source file:at.ac.tuwien.big.moea.print.PopulationWriter.java

@Override
public String write(final Iterable<S> population) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    write(ps, population);/*from  w  w w.jav a 2 s. co  m*/
    ps.close();
    try {
        return baos.toString("UTF-8");
    } catch (final UnsupportedEncodingException e) {
        return e.getMessage();
    }
}

From source file:at.ac.tuwien.big.moea.print.PopulationWriter.java

@Override
public String write(final Population population) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    write(ps, population);//from   w w w  .j  a va 2s.  co m
    ps.close();
    try {
        return baos.toString("UTF-8");
    } catch (final UnsupportedEncodingException e) {
        return e.getMessage();
    }
}

From source file:biblivre3.marcutils.MarcUtils.java

public static Record iso2709ToRecord(String iso2709, boolean logging) {
    Record record = null;/*from   w ww . ja  va 2  s  . c o  m*/
    try {
        ByteArrayInputStream bais = new ByteArrayInputStream(iso2709.getBytes("UTF-8"));
        MarcStreamReader reader = new MarcStreamReader(bais, "UTF-8");

        if (reader.hasNext()) {
            record = reader.next();
        }
    } catch (UnsupportedEncodingException uee) {
        if (logging) {
            log.error(uee.getMessage(), uee);
        }
    } catch (MarcException me) {
        if (logging) {
            log.error(me.getMessage(), me);
        }
        record = iso2709ToRecordAsIso(iso2709);
    }
    return record;
}

From source file:com.aliyun.odps.account.AliyunRequestSigner.java

public String getSignature(String resource, Request req) {
    try {/*  w ww.jav a 2  s  .c  om*/
        resource = URLDecoder.decode(resource, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    String strToSign = SecurityUtils.buildCanonicalString(resource, req, "x-odps-");

    if (log.isLoggable(Level.FINE)) {
        log.fine("String to sign: " + strToSign);
    }

    byte[] crypto = new byte[0];
    try {
        crypto = SecurityUtils.hmacsha1Signature(strToSign.getBytes("UTF-8"), accessKey.getBytes());
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    String signature = Base64.encodeBase64String(crypto).trim();

    return "ODPS " + accessId + ":" + signature;
}

From source file:org.dataconservancy.ui.it.support.ValidatingMetadataFileRequest.java

public HttpPost asHttpPost() {
    if (fileToTest == null) {
        throw new IllegalStateException("File not set: call setFileToTest(File) first");
    }/*from   w  w  w  . j  ava 2s  .c  om*/

    String validatingMetadataFileUrl = urlConfig.getAdminValidatingMetadataFilePathPostUrl().toString();
    HttpPost post = new HttpPost(validatingMetadataFileUrl);
    MultipartEntity entity = new MultipartEntity();
    try {
        entity.addPart(STRIPES_EVENT, new StringBody("Validate", Charset.forName("UTF-8")));
        entity.addPart("metadataFormatId", new StringBody(formatId, Charset.forName("UTF-8")));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    FileBody fileBody = new FileBody(fileToTest);
    entity.addPart("sampleMetadataFile", fileBody);
    post.setEntity(entity);

    return post;
}

From source file:io.dacopancm.jfee.managedController.FacturaAfiliacionBean.java

@PostConstruct
public void postConstruct() {

    try {/*from   w  w w  .j  a v  a 2  s  . c  o  m*/
        Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext()
                .getRequestParameterMap();
        if (params.containsKey("r")) {
            returnPage = params.get("r");
        }
        if (params.containsKey("socCi") && params.containsKey("h")) {
            String hash = UriUtils.decode(params.get("h"), "UTF-8");
            String ci = params.get("socCi");
            if (BCrypt.checkpw(ci, hash)) {
                selectedSocio = socioService.getSocioByCi(ci);
            }
        } else {
            //redirect to index
        }
    } catch (UnsupportedEncodingException ex) {
        log.error(ex.getMessage());
        //redirect to index
    }

}

From source file:com.aliyun.datahub.auth.AliyunRequestSigner.java

public String getSignature(String resource, DefaultRequest req) {
    try {// ww  w  .  ja  v  a2 s.  c om
        resource = URLDecoder.decode(resource, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    String strToSign = SecurityUtils.buildCanonicalString(resource, req, "x-datahub-");

    if (log.isLoggable(Level.FINE)) {
        log.fine("String to sign: " + strToSign);
    }

    byte[] crypto = SecurityUtils.hmacsha1Signature(strToSign.getBytes(), accessKey.getBytes());

    String signature = Base64.encodeBase64String(crypto).trim();

    return "DATAHUB " + accessId + ":" + signature;
}

From source file:org.jasig.cas.util.http.HttpMessage.java

/**
 * Encodes the message in UTF-8 format in preparation to send.
 * @param message Message to format and encode
 * @return The encoded message.//from w  ww.  j ava  2  s. c  om
 */
protected String formatOutputMessageInternal(final String message) {
    try {
        return URLEncoder.encode(message, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
        LOGGER.warn(e.getMessage(), e);
    }
    return message;
}

From source file:org.focusns.common.web.page.engine.widget.WidgetResponse.java

public String getResponseAsString() {
    try {//  ww w .jav a 2s.c o  m
        String charEncoding = getResponse().getCharacterEncoding();
        if (StringUtils.hasText(charEncoding)) {
            return content.toString(charEncoding);
        }
        return content.toString();
    } catch (UnsupportedEncodingException e) {
        return e.getMessage();
    }
}