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:com.google.gerrit.server.account.HashedPassword.java
private static byte[] hashPassword(String password, byte[] salt, int cost) { byte[] pwBytes = password.getBytes(StandardCharsets.UTF_8); return BCrypt.generate(pwBytes, salt, cost); }
From source file:eu.freme.eservices.pipelines.core.Conversion.java
public String htmlToNif(final String html) throws IOException, ConversionException { try (InputStream in = IOUtils.toInputStream(html, StandardCharsets.UTF_8)) { try (Reader reader = eInternationalizationApi.convertToTurtleWithMarkups(in, EInternationalizationAPI.MIME_TYPE_HTML)) { skeletonNIF = IOUtils.toString(reader); }/*from ww w. j a v a 2 s.co m*/ } try (InputStream in = IOUtils.toInputStream(html, StandardCharsets.UTF_8)) { try (Reader reader = eInternationalizationApi.convertToTurtle(in, EInternationalizationAPI.MIME_TYPE_HTML)) { return IOUtils.toString(reader); } } }
From source file:com.conwet.xjsp.features.MessageChannel.java
synchronized public void sendFragment(String fragment) throws IOException { ByteBuffer buffer = ByteBuffer.wrap(fragment.getBytes(StandardCharsets.UTF_8)); try {/*from ww w. j a va 2 s . c om*/ while (buffer.hasRemaining()) { channel.write(buffer); } } catch (IOException ex) { logger.error("Closing connection on exception", ex); throw ex; } }
From source file:com.datumbox.framework.applications.nlp.CETRTest.java
/** * Test of extract method, of class CETR. *//* ww w . j ava 2 s . c om*/ @Test public void testExtract() { logger.info("extract"); Configuration conf = Configuration.getConfiguration(); String dbName = this.getClass().getSimpleName(); String text; try { List<String> lines = Files.readAllLines( Paths.get(this.getClass().getClassLoader().getResource("datasets/example.com.html").toURI()), StandardCharsets.UTF_8); text = StringUtils.join(lines, "\r\n"); } catch (IOException | URISyntaxException ex) { throw new RuntimeException(ex); } CETR.Parameters parameters = new CETR.Parameters(); parameters.setNumberOfClusters(2); parameters.setAlphaWindowSizeFor2DModel(3); parameters.setSmoothingAverageRadius(2); CETR instance = new CETR(dbName, conf); String expResult = "This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission."; String result = instance.extract(text, parameters); assertEquals(expResult, result); }
From source file:costumetrade.common.sms.SMSActor.java
private void doSend(Sms sms) { String ecodingContent = null; try {//w w w . j a v a2s. c o m ecodingContent = URLEncoder.encode(sms.content, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException ignore) { } StringBuilder params = new StringBuilder(); params.append("action=").append(ConfigProperties.getProperty("sms.action")).append("&userid=") .append(ConfigProperties.getProperty("sms.userid")).append("&account=") .append(ConfigProperties.getProperty("sms.account")).append("&password=") .append(ConfigProperties.getProperty("sms.password")).append("&mobile=").append(sms.mobile) .append("&content=").append(ecodingContent); String xml = sendPostRequestByForm(ConfigProperties.getProperty("sms.url"), params.toString()); boolean success = isOk(xml); if (!success) { if (sms.retryCount > 0) { scheduler.scheduleOnce(Duration.create(sms.interval, TimeUnit.SECONDS), getSelf(), new Sms(sms.mobile, sms.content, sms.retryCount - 1), dispatcher, ActorRef.noSender()); } } }
From source file:com.diffplug.gradle.ZipMisc.java
/** * Reads the given entry from the zip.//from w ww. j a v a 2s .c o m * * @param input a zip file * @param toRead a path within that zip file * @return the given path within the zip file decoded as a UTF8 string, with only unix newlines. */ public static String read(File input, String toRead) throws IOException { String raw = StringPrinter.buildString(Errors.rethrow().wrap(printer -> { read(input, toRead, inputStream -> { copy(inputStream, printer.toOutputStream(StandardCharsets.UTF_8)); }); })); return FileMisc.toUnixNewline(raw); }
From source file:io.wcm.devops.conga.plugins.aem.tooling.crypto.cli.AnsibleVaultTest.java
@Test public void testEncryptDecrypt() throws Exception { FileUtils.write(testFile, TEST_CONTENT, StandardCharsets.UTF_8); // encrypt file AnsibleVault.encrypt(testFile);/* w w w. ja va2 s .c om*/ String content = FileUtils.readFileToString(testFile, StandardCharsets.UTF_8); assertNotEquals(TEST_CONTENT, content); // decrypt file AnsibleVault.decrypt(testFile); content = FileUtils.readFileToString(testFile, StandardCharsets.UTF_8); assertEquals(TEST_CONTENT, content); }
From source file:com.blackducksoftware.integration.hub.detect.testutils.TestUtil.java
public String getResourceAsUTF8String(final String resourcePath) { final String data; try {//from www.j av a2 s .com data = ResourceUtil.getResourceAsString(getClass(), resourcePath, StandardCharsets.UTF_8.toString()); } catch (final IOException e) { throw new RuntimeException(e); } return Arrays.asList(data.split("\r?\n")).stream().collect(Collectors.joining(System.lineSeparator())); }
From source file:com.twosigma.beakerx.security.HashedMessageAuthenticationCode.java
public String sign(List<String> msg) { List<byte[]> collect = msg.stream().map(x -> x.getBytes(StandardCharsets.UTF_8)) .collect(Collectors.toList()); return signBytes(collect); }
From source file:mtsar.api.csv.WorkerCSV.java
public static void write(Collection<Worker> workers, OutputStream output) throws IOException { try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { final Iterable<String[]> iterable = () -> workers.stream().sorted(ORDER) .map(worker -> new String[] { Integer.toString(worker.getId()), // id worker.getStage(), // stage Long.toString(worker.getDateTime().toInstant().getEpochSecond()), // datetime String.join("|", worker.getTags()), // tags }).iterator();/*from w ww .j a v a 2 s. co m*/ FORMAT.withHeader(HEADER).print(writer).printRecords(iterable); } }