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.joyent.manta.client.MantaClientFindIT.java
public void canFindASingleFile() throws IOException { String filePath = testPathPrefix + UUID.randomUUID(); mantaClient.put(filePath, TEST_DATA, StandardCharsets.UTF_8); try (Stream<MantaObject> stream = mantaClient.find(testPathPrefix)) { List<MantaObject> results = stream.collect(Collectors.toList()); Assert.assertFalse(results.isEmpty(), "We should have at least one file returned"); Assert.assertEquals(results.get(0).getPath(), filePath); Assert.assertFalse(results.get(0).isDirectory()); }/*from w ww .j a v a 2 s .co m*/ }
From source file:io.kamax.mxisd.threepid.notification.GenericTemplateNotificationGenerator.java
private String getTemplateContent(String location) { try {/* ww w. ja v a 2s . c o m*/ InputStream is = StringUtils.startsWith(location, "classpath:") ? app.getResource(location).getInputStream() : new FileInputStream(location); return IOUtils.toString(is, StandardCharsets.UTF_8); } catch (IOException e) { throw new InternalServerError("Unable to read template content at " + location + ": " + e.getMessage()); } }
From source file:de.pixida.logtest.tutorial.TutorialAutomatonsTest.java
private boolean getExecutionResultOfAutomatonOnTutorialLog(final String automatonName) { final String tutorialFolder = "/tutorial"; BufferedReader br = null;/* ww w. j av a 2s.com*/ try { br = new BufferedReader(new StringReader(FileUtils.readFileToString( new File(this.getClass().getResource(tutorialFolder + "/log.txt").getFile()), StandardCharsets.UTF_8))); } catch (final IOException e) { Assert.fail(e.getMessage()); } final LogSink sink = new LogSink(); try { sink.setAutomaton(new JsonAutomatonDefinition( new File(this.getClass().getResource(tutorialFolder + "/" + automatonName + ".json").toURI()))); } catch (final URISyntaxException e) { Assert.fail(e.getMessage()); } sink.setParameters(Collections.emptyMap()); final Job job = new Job(); job.setLogReader(new GenericLogReader(br)); job.setSinks(Arrays.asList(sink)); final JobExecutor jobExecutor = new JobExecutor(Arrays.asList(job)); final List<List<EvaluationResult>> results = jobExecutor.getResults(); Assert.assertEquals(1, results.size()); Assert.assertEquals(1, results.get(0).size()); return results.get(0).get(0).isSuccess(); }
From source file:eu.freme.eservices.pipelines.core.Conversion.java
public String nifToHtml(final String enrichedNIF) throws IOException { try (InputStream enrichedFile = IOUtils.toInputStream(enrichedNIF, StandardCharsets.UTF_8); InputStream skeletonFile = IOUtils.toInputStream(skeletonNIF, StandardCharsets.UTF_8)) { try (Reader htmlReader = eInternationalizationApi.convertBack(skeletonFile, enrichedFile)) { String html = IOUtils.toString(htmlReader); skeletonNIF = ""; return html; }//from ww w . j a v a 2 s . com } }
From source file:com.netflix.dyno.connectionpool.impl.utils.ZipUtils.java
/** * Decompresses the given byte array//from w w w .j a va2s . c o m * * @param compressed byte array input * @return decompressed data in string format * @throws IOException */ public static String decompressStringNonBase64(byte[] compressed) throws IOException { ByteArrayInputStream is = new ByteArrayInputStream(compressed); InputStream gis = new GZIPInputStream(is); return new String(IOUtils.toByteArray(gis), StandardCharsets.UTF_8); }
From source file:hudson.console.HyperlinkNoteTest.java
private static String annotate(String text) throws IOException { StringWriter writer = new StringWriter(); try (ConsoleAnnotationOutputStream out = new ConsoleAnnotationOutputStream(writer, null, null, StandardCharsets.UTF_8)) { IOUtils.copy(new StringReader(text), out); }//from w w w . jav a2 s. c o m return writer.toString(); }
From source file:cc.redpen.formatter.JSONFormatter.java
@Override public String format(Document document, List<ValidationError> errors) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedWriter writer = new BufferedWriter(new PrintWriter(baos)); try {/* w w w . j ava 2s . c o m*/ writer.write(asJSON(document, errors).toString()); writer.flush(); } catch (IOException e) { throw new RuntimeException(e); } return new String(baos.toByteArray(), StandardCharsets.UTF_8); }
From source file:com.hurence.logisland.processor.hbase.io.TestJsonQualifierAndValueRowSerializer.java
@Test public void testSerializeRegular() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RowSerializer rowSerializer = new JsonQualifierAndValueRowSerializer(StandardCharsets.UTF_8, StandardCharsets.UTF_8); rowSerializer.serialize(rowKey, cells, out); final String json = out.toString(StandardCharsets.UTF_8.name()); Assert.assertEquals("{\"" + QUAL1 + "\":\"" + VAL1 + "\", \"" + QUAL2 + "\":\"" + VAL2 + "\"}", json); }
From source file:net.slkdev.swagger.confluence.service.impl.SwaggerToAsciiDocServiceImpl.java
@Override public String convertSwaggerToAsciiDoc(final String swaggerSchemaPath) { final File swaggerSchemaFile; LOG.info("Converting Swagger Schema to Ascii Doc..."); try {/*from ww w .j a va 2 s .co m*/ swaggerSchemaFile = getSchemaFile(swaggerSchemaPath); } catch (final FileNotFoundException | URISyntaxException e) { throw new SwaggerConfluenceConfigurationException("Error Locating Swagger Schema", e); } final String swaggerAsciiDoc; try { final Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withMarkupLanguage(MarkupLanguage.ASCIIDOC).withOutputLanguage(Language.EN) .withPathsGroupedBy(GroupBy.AS_IS).withOperationOrdering(OrderBy.AS_IS).build(); final String swaggerSchema = FileUtils.readFileToString(swaggerSchemaFile, StandardCharsets.UTF_8); swaggerAsciiDoc = Swagger2MarkupConverter.from(swaggerSchema).withConfig(config).build().toString(); } catch (IOException e) { throw new SwaggerConfluenceInternalSystemException("Error Converting Swagger Schema to AsciiDoc", e); } LOG.info("AsciiDoc Conversion Complete!"); return swaggerAsciiDoc; }