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:com.haulmont.chile.core.datatypes.impl.ByteArrayDatatype.java

@Override
public String format(Object value) {
    if (value == null)
        return "";

    return new String(Base64.encodeBase64((byte[]) value), StandardCharsets.UTF_8);
}

From source file:com.github.tddts.jet.oauth.impl.QueryParserImpl.java

@Override
public Map<String, String> parseQuery(String query) {
    return toMap(URLEncodedUtils.parse((query), StandardCharsets.UTF_8));
}

From source file:com.rodrigodev.xgen4j_table_generator.test.common.StringUtils.java

public static InputStream toInputStream(String aValue) {
    return IOUtils.toInputStream(aValue, StandardCharsets.UTF_8);
}

From source file:com.vmware.o11n.plugin.crypto.service.CryptoEncodingService.java

/**
 *
 * @param data/*w ww  .  java 2 s . co m*/
 * @return
 * @throws UnsupportedEncodingException
 */
public String base64Encode(String data) throws UnsupportedEncodingException {
    String encoded = new String(Base64.encodeBase64(data.getBytes(StandardCharsets.UTF_8)));
    return encoded;
}

From source file:io.servicecomb.common.rest.codec.produce.ProduceTextPlainProcessor.java

@Override
public void doEncodeResponse(OutputStream output, Object result) throws Exception {
    output.write(String.valueOf(result).getBytes(StandardCharsets.UTF_8));
}

From source file:io.dockstore.client.cli.CWLClientTest.java

@Test
public void serializeToJson() throws Exception {
    final URL resource = Resources.getResource("cwl.json");
    final String cwlJson = Resources.toString(resource, StandardCharsets.UTF_8);

    final CWL cwl = new CWL();

    final Gson gson = CWL.getTypeSafeCWLToolDocument();
    final Map<String, Object> runJson = cwl.extractRunJson(cwlJson);
    final String s = gson.toJson(runJson);
    assertTrue(s.length() > 10);//from  w w  w.  j a  v a  2  s.c o m
}

From source file:edu.jhu.hlt.alnc.ALNCFileConverter.java

/**
 * Wrap an {@link InputStream} that represents ALNC JSON, one JSON object per line.
 *
 * @param is an {@link InputStream} over properly formed ALNC JSON data
 */// w  ww.ja va2  s .co m
public ALNCFileConverter(InputStream is) {
    this.is = is;
    this.isr = new InputStreamReader(is, StandardCharsets.UTF_8);
    this.br = new BufferedReader(this.isr, 1024 * 8 * 8 * 4);
}

From source file:com.sonar.maven.it.suite.AbstractMavenTest.java

protected static Version mojoVersion() {
    if (mojoVersion == null) {
        try {//from  w  ww . j ava 2  s .  c om
            for (String line : Files.readAllLines(Paths.get("../pom.xml"), StandardCharsets.UTF_8)) {
                if (line.startsWith("  <version>")) {
                    String version = StringUtils.substringAfter(line, "<version>");
                    version = StringUtils.substringBefore(version, "</version>");
                    mojoVersion = Version.create(version);
                    return mojoVersion;
                }
            }
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        throw new IllegalStateException("Unable to find version of the Maven plugin to be used by ITs");
    }
    return mojoVersion;
}

From source file:com.vmware.identity.rest.core.util.RequestSigner.java

/**
 * Signs a string using the private key and SHA 256 with RSA signing algorithm, and
 * returns it as a hex-encoded string.//from w w w  . j  ava 2 s .c  om
 *
 * @param signingString the string to sign.
 * @param privateKey the private key to sign the string with.
 * @return the signed string in a hex-encoded format.
 * @throws InvalidKeyException if the key is invalid.
 * @throws SignatureException if the signature algorithm is unable to process the input
 * data provided.
 */
public static String sign(String signingString, PrivateKey privateKey)
        throws InvalidKeyException, SignatureException {
    byte[] bytes = signingString.getBytes(StandardCharsets.UTF_8);

    Signature sig;

    try {
        sig = Signature.getInstance(SHA256_WITH_RSA);
    } catch (NoSuchAlgorithmException e) {
        throw new IllegalArgumentException("An error occurred while getting the signature algorithm", e);
    }

    sig.initSign(privateKey);
    sig.update(bytes);

    return Hex.encodeHexString(sig.sign());
}

From source file:com.byteatebit.common.io.TestFileStreamSource.java

@Test
public void testGetInputStream() throws IOException {
    File file = tempFolder.newFile("file1.txt");
    String message = "Sample message";
    FileUtils.write(file, message, StandardCharsets.UTF_8);
    IStreamSource streamSource = new FileStreamSource(file);
    try (InputStream in = streamSource.getInputStream()) {
        String fileMessage = IOUtils.toString(in, StandardCharsets.UTF_8);
        Assert.assertEquals(message, fileMessage);
    }//from www .j ava  2  s  .  co m
}