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:cn.codepub.redis.directory.io.InputOutputStream.java

default String[] getAllFileNames(String directoryMedata) {
    Objects.requireNonNull(directoryMedata);
    Set<byte[]> hkeys = hkeys(directoryMedata.getBytes());
    Objects.requireNonNull(hkeys);
    ArrayList<String> names = Lists.newArrayList();
    hkeys.forEach(key -> names.add(new String(key, StandardCharsets.UTF_8)));
    return names.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}

From source file:com.coffeebeans.services.config.ServicesConfig.java

@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
    resource.setBasename("messages");
    resource.setDefaultEncoding(StandardCharsets.UTF_8.toString());
    return resource;
}

From source file:love.sola.netsupport.util.RSAUtil.java

public static String decrypt(String encrypted) {
    try {//from w w w .  j av a 2s .c  o m
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, privateKey);
        byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
        return new String(original, StandardCharsets.UTF_8);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;
}

From source file:com.stratio.mojo.scala.crossbuild.FileRewriter.java

public void rewrite(final File file) throws IOException {
    if (!file.exists()) {
        throw new FileNotFoundException("File does not exist: " + file);
    }//from w w  w .j  a v  a2  s.c o  m
    backupFile(file);
    String result = IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8);
    for (final RewriteRule rule : rules) {
        result = rule.replace(result);
    }
    IOUtils.write(result, new FileOutputStream(file), StandardCharsets.UTF_8);
}

From source file:com.blackducksoftware.integration.hub.detect.tool.bazel.BazelExternalIdExtractionFullRuleJsonProcessor.java

public List<BazelExternalIdExtractionFullRule> load(File jsonFile) throws IOException {
    String json = FileUtils.readFileToString(jsonFile, StandardCharsets.UTF_8);
    BazelExternalIdExtractionFullRule[] rulesArray = gson.fromJson(json,
            BazelExternalIdExtractionFullRule[].class);
    return Arrays.asList(rulesArray);
}

From source file:com.lexicalintelligence.admin.get.MapGetRequest.java

@SuppressWarnings("unchecked")
public <T extends LexicalResponse> T execute() {
    MapGetResponse searchResponse;/*from w  w  w  .ja  v  a  2  s.c o m*/
    Reader reader = null;
    try {
        HttpResponse response = client.getHttpClient().execute(new HttpGet(client.getUrl() + PATH + getPath()));
        reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8);
        Map<String, String> items = client.getObjectMapper().readValue(reader,
                new TypeReference<Map<String, String>>() {
                });
        searchResponse = new MapGetResponse(true);
        searchResponse.setItems(items);
    } catch (Exception e) {
        searchResponse = new MapGetResponse(false);
        log.error(e);
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
            log.error(e);
        }
    }
    return (T) searchResponse;
}

From source file:de.elomagic.mag.ConfigurationTest.java

@Before
public void beforeConfigurationTest() throws Exception {
    String text = IOUtils.toString(getClass().getResourceAsStream("/configuration.properties"), "utf-8");
    Files.write(text, file, StandardCharsets.UTF_8);
}

From source file:com.lexicalintelligence.admin.get.ListGetRequest.java

@SuppressWarnings("unchecked")
public <T extends LexicalResponse> T execute() {
    ListGetResponse searchResponse;/*from  ww w  .j av  a 2s.  co m*/
    Reader reader = null;
    try {
        HttpResponse response = client.getHttpClient().execute(new HttpGet(client.getUrl() + PATH + getPath()));
        reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8);
        List<String> items = client.getObjectMapper().readValue(reader, new TypeReference<List<String>>() {
        });
        searchResponse = new ListGetResponse(true);
        searchResponse.setItems(items);
    } catch (Exception e) {
        searchResponse = new ListGetResponse(false);
        log.error(e);
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
            log.error(e);
        }
    }
    return (T) searchResponse;
}

From source file:at.ac.tuwien.dsg.depic.external.algorithm.MySqlDataAssetStore.java

public void storeDataAsset(DataAsset da) {

    try {//from w ww.j a va  2s . c  om
        String daXML = JAXBUtils.marshal(da, DataAsset.class);

        //   Logger.getLogger(MySqlDataAssetStore.class.getName()).log(Level.INFO, "Prepare to Store: " + daXML);
        InputStream daStream = new ByteArrayInputStream(daXML.getBytes(StandardCharsets.UTF_8));
        List<InputStream> listOfInputStreams = new ArrayList<InputStream>();
        listOfInputStreams.add(daStream);

        String sql = "INSERT INTO DataAsset (dataAssetID, dataPartitionID, data) VALUES ('"
                + da.getDataAssetID() + "'," + da.getPartition() + ",?)";

        connectionManager.ExecuteUpdateBlob(sql, listOfInputStreams);

    } catch (Exception ex) {
        Logger.getLogger(MySqlDataAssetStore.class.getName()).log(Level.SEVERE, ex.toString());
    }

}

From source file:cop.raml.TestUtils.java

public static String getResourceAsString(String path) {
    try (InputStream in = TestUtils.class.getClassLoader().getResourceAsStream(path)) {
        return IOUtils.toString(in, StandardCharsets.UTF_8).trim();
    } catch (Exception ignored) {
        return null;
    }//from ww w .j  a  va 2  s  . co  m
}