List of usage examples for java.nio.charset StandardCharsets UTF_8
Charset UTF_8
To view the source code for java.nio.charset StandardCharsets UTF_8.
Click Source Link
From source file:mtsar.api.csv.WorkerRankingCSV.java
public static void write(Collection<WorkerRanking> rankings, OutputStream output) throws IOException { try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { final Iterable<String[]> iterable = () -> rankings.stream().sorted(ORDER) .map(aggregation -> new String[] { Integer.toString(aggregation.getWorker().getId()), // worker_id Double.toString(aggregation.getReputation()) // reputation }).iterator();//from ww w . java2 s . co m FORMAT.withHeader(HEADER).print(writer).printRecords(iterable); } }
From source file:Main.java
private static Document readString(String xmlSource) throws IOException, SAXException, ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); return docBuilder.parse(new ByteArrayInputStream(xmlSource.getBytes(StandardCharsets.UTF_8))); }
From source file:mtsar.api.csv.AnswerAggregationCSV.java
public static void write(Collection<AnswerAggregation> aggregations, OutputStream output) throws IOException { try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { final Iterable<String[]> iterable = () -> aggregations.stream().sorted(ORDER) .map(aggregation -> new String[] { Integer.toString(aggregation.getTask().getId()), // task_id String.join("|", aggregation.getAnswers()) // answers }).iterator();//w w w .jav a 2 s.co m FORMAT.withHeader(HEADER).print(writer).printRecords(iterable); } }
From source file:com.ro.ssc.app.client.licensing.TrialKeyValidator.java
public static String decodeKey(String encodedEncrypted) { String decoded = ""; try {//from w w w .jav a 2 s .c o m byte[] saltDecrypt = SALT_DECRYPT.getBytes(StandardCharsets.UTF_8); SecretKeyFactory factoryKeyDecrypt = SecretKeyFactory.getInstance(SECRET_KEY_FACTORY); SecretKey tmp2 = factoryKeyDecrypt.generateSecret( new PBEKeySpec(PASS_DECRYPT.toCharArray(), saltDecrypt, ITERATIONS_DECRYPT, KEY_LENGTH)); SecretKeySpec decryptKey = new SecretKeySpec(tmp2.getEncoded(), ALGORITHM); Cipher aesCipherDecrypt = Cipher.getInstance(CIPHER); aesCipherDecrypt.init(Cipher.DECRYPT_MODE, decryptKey); byte[] e64bytes = StringUtils.getBytesUtf8(encodedEncrypted); byte[] eBytes = Base64.decodeBase64(e64bytes); byte[] cipherDecode = aesCipherDecrypt.doFinal(eBytes); decoded = StringUtils.newStringUtf8(cipherDecode); } catch (Exception e) { LOGGER.error("Error while decoding the trial key", e); } return decoded; }
From source file:com.seguriboxltv.core.util.Util.java
public String BytesToString(byte[] arrayByte, short codigo) { return new String(arrayByte, StandardCharsets.UTF_8); }
From source file:com.netflix.dyno.connectionpool.impl.utils.ZipUtils.java
public static byte[] compressString(String value) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(value.length()); GZIPOutputStream gos = new GZIPOutputStream(baos); gos.write(Base64.encode(value.getBytes(StandardCharsets.UTF_8))); gos.close();//from w ww. java 2 s . c om byte[] compressed = baos.toByteArray(); baos.close(); return compressed; }
From source file:io.cloudslang.lang.runtime.configuration.SlangRuntimeSpringConfig.java
private static void setPythonIoEncoding() { String encodingValue = System.getProperty(SlangSystemPropertyConstant.CSLANG_ENCODING.getValue()); if (StringUtils.isEmpty(encodingValue)) { encodingValue = StandardCharsets.UTF_8.name(); }/*from w w w.j av a 2 s . c o m*/ System.getProperties().setProperty(PySystemState.PYTHON_IO_ENCODING, encodingValue); }
From source file:cd.go.contrib.elasticagents.docker.utils.Util.java
public static String readResource(String resourceFile) { try (InputStreamReader reader = new InputStreamReader( GetViewRequestExecutor.class.getResourceAsStream(resourceFile), StandardCharsets.UTF_8)) { return CharStreams.toString(reader); } catch (IOException e) { throw new RuntimeException("Could not find resource " + resourceFile, e); }//from ww w.j a va2s . com }
From source file:com.gooddata.util.ResourceUtils.java
public static String readStringFromResource(String resourcePath) { try {//from www .j av a2s .co m return IOUtils.toString(readFromResource(resourcePath), StandardCharsets.UTF_8); } catch (IOException e) { throw new IllegalStateException(format("Cannot read from resource %s", resourcePath), e); } }
From source file:com.github.jinahya.codec.PercentCodecTestHelper.java
public static byte[] decodedBytes(final int maxlen) { return decodedString(maxlen).getBytes(StandardCharsets.UTF_8); }