Example usage for java.nio.charset StandardCharsets UTF_8

List of usage examples for java.nio.charset StandardCharsets UTF_8

Introduction

In this page you can find the example usage for java.nio.charset StandardCharsets UTF_8.

Prototype

Charset UTF_8

To view the source code for java.nio.charset StandardCharsets UTF_8.

Click Source Link

Document

Eight-bit UCS Transformation Format.

Usage

From source file:br.com.rp.services.EmailService.java

private static HtmlEmail configurarEmailPadrao() throws EmailException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName("smtp.gmail.com");
    email.setSmtpPort(465);/*  w w w.  j  a  v a2s.co m*/
    email.setAuthentication(ENDERECO_EMAIL, SENHA);
    email.setSSLOnConnect(true);
    email.setCharset(StandardCharsets.UTF_8.toString());
    email.setFrom(ENDERECO_EMAIL, "Sistema VBANK");
    return email;
}

From source file:com.github.ambry.frontend.AmbryIdSigningService.java

@Override
public String getSignedId(String blobId, Map<String, String> metadata) throws RestServiceException {
    try {/*from   w  w w . j  a va 2 s.c o  m*/
        String jsonString = SignedIdSerDe.toJson(blobId, metadata);
        return RestUtils.SIGNED_ID_PREFIX
                + Base64.encodeBase64URLSafeString(jsonString.getBytes(StandardCharsets.UTF_8));
    } catch (Exception e) {
        throw new RestServiceException("Error serializing signed ID", e,
                RestServiceErrorCode.InternalServerError);
    }
}

From source file:com.haulmont.chile.core.datatypes.impl.ByteArrayDatatype.java

@Override
public byte[] parse(String value) throws ParseException {
    if (value == null || value.length() == 0)
        return null;

    return Base64.decodeBase64(value.getBytes(StandardCharsets.UTF_8));
}

From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineToolTest.java

@Test
public void testMain_multiple_formulae_non_operators() throws Exception {

    String testFile = "multiple-formulae";

    String[] argv = { getTestResourceAsFilepath(testFile + ".input.xml") };

    ByteArrayOutputStream stdoutContent = new ByteArrayOutputStream();
    PrintStream stdout = System.out;

    System.setOut(new PrintStream(stdoutContent));
    MathMLUnificatorCommandLineTool.main(argv);
    System.setOut(stdout);/*w w  w . j a  va  2  s. c  o m*/

    String output = stdoutContent.toString(StandardCharsets.UTF_8.toString());

    System.out.println("testMain_multiple_formulae_non_operators  non-operators output:\n" + output);
    assertEquals(
            IOUtils.toString(getExpectedXMLTestResource(testFile + ".non-operator"), StandardCharsets.UTF_8),
            output);

}

From source file:test.pl.chilldev.web.tags.page.ScriptTagTest.java

@Test
public void doTag() throws JspTagException {
    JspContext context = new MockPageContext();
    ScriptTag tag = new ScriptTag();
    tag.setJspContext(context);//from  w w w  . j a va 2 s .com

    // set up context
    String attribute = "foo";
    context.setAttribute(attribute, this.page);

    // set up resolver
    PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute));

    String src = "bar";
    String type = "baz";
    Element.Flow flow = Element.Flow.DEFER;
    Charset charset = StandardCharsets.UTF_8;

    // run the tag
    tag.setSrc(src);
    tag.setType(type);
    tag.setFlow(flow);
    tag.setCharset(charset);
    tag.doTag();

    verify(this.page).addScript(src, type, flow, charset);
}

From source file:cop.raml.processor.SimpleJavaFileObjectImpl.java

@Override
public CharSequence getCharContent(boolean b) throws IOException {
    return FileUtils.readFileToString(file, StandardCharsets.UTF_8);
}

From source file:io.github.restdocsext.jersey.JerseyResponseConverterTest.java

@Test
public void convers_response() {
    final ClientResponse clientResponse = Mocks.clientResponseBuilder().status(200)
            .header("X-Response-Header1", "SomeValue1").header("X-Response-Header2", "SomeValue2")
            .requestContext(Mocks.clientRequestBuilder()
                    .configProp(RESPONSE_BODY_KEY, "Testing".getBytes(StandardCharsets.UTF_8)).build())
            .build();/*from   w ww.j av  a  2  s  .  co  m*/
    final OperationResponse response = new JerseyResponseConverter().convert(clientResponse);
    assertThat(response.getContentAsString(), is("Testing"));
    assertThat(response.getStatus().value(), is(200));
    assertThat(response.getHeaders().getFirst("X-Response-Header1"), is("SomeValue1"));
    assertThat(response.getHeaders().getFirst("X-Response-Header2"), is("SomeValue2"));
}

From source file:edu.kit.scc.cdmi.rest.AuthorizationTest.java

@Test
public void testBasicAuthorization() {
    String auth = restUser + ":" + restPassword;
    byte[] authZheader = auth.getBytes();
    String authorizationHeader = "Basic "
            + new String(Base64.encodeBase64(authZheader), StandardCharsets.UTF_8);

    //    assertTrue(controller.verifyAuthorization(authorizationHeader));
}

From source file:model.SummaryList.java

public SummaryList() {
    BufferedReader inputFile = new BufferedReader(
            new InputStreamReader(getClass().getResourceAsStream(CSV_FILENAME)));
    CSV csv = CSV.separator(',').charset(StandardCharsets.UTF_8).skipLines(1).quote('"').create();
    csv.read(inputFile, new CSVReadProc() {

        @Override//from w w w .ja v  a  2s.  c o  m
        public void procRow(int i, String... strings) {
            summaryList.add(new Summary(strings[0].trim(), Double.parseDouble(strings[1].trim()),
                    Double.parseDouble(strings[2].trim()), Double.parseDouble(strings[3].trim()),
                    (strings[4].isEmpty()) ? -1 : Double.parseDouble(strings[4].trim())));
        }
    });

}

From source file:com.jivesoftware.os.amza.api.ring.RingHost.java

public byte[] toBytes() { // TODO convert to lex byte ordering?
    byte[] hostBytes = host.getBytes(StandardCharsets.UTF_8);
    byte[] rackBytes = rack.getBytes(StandardCharsets.UTF_8);
    byte[] datacenterBytes = datacenter.getBytes(StandardCharsets.UTF_8);
    byte[] bytes = new byte[1 + 4 + 4 + hostBytes.length + 4 + rackBytes.length + 4 + datacenterBytes.length];
    int i = 0;// w ww .j  av  a  2  s .c  o m
    bytes[i] = 1; // version;
    i++;
    UIO.intBytes(port, bytes, i);
    i += 4;
    UIO.intBytes(hostBytes.length, bytes, i);
    i += 4;
    UIO.writeBytes(hostBytes, bytes, i);
    i += hostBytes.length;
    UIO.intBytes(rackBytes.length, bytes, i);
    i += 4;
    UIO.writeBytes(rackBytes, bytes, i);
    i += rackBytes.length;
    UIO.intBytes(datacenterBytes.length, bytes, i);
    i += 4;
    UIO.writeBytes(datacenterBytes, bytes, i);
    return bytes;
}