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:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceOpenShiftTest.java
private static String filenameToString(String path) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, StandardCharsets.UTF_8); }
From source file:eu.itesla_project.modules.offline.ExportSecurityIndexesTool.java
@Override public void run(CommandLine line) throws Exception { String simulationDbName = line.hasOption("simulation-db-name") ? line.getOptionValue("simulation-db-name") : OfflineConfig.DEFAULT_SIMULATION_DB_NAME; OfflineConfig config = OfflineConfig.load(); OfflineDb offlineDb = config.getOfflineDbFactoryClass().newInstance().create(simulationDbName); String workflowId = line.getOptionValue("workflow"); Path outputFile = Paths.get(line.getOptionValue("output-file")); char delimiter = ';'; if (line.hasOption("delimiter")) { String value = line.getOptionValue("delimiter"); if (value.length() != 1) { throw new RuntimeException("A character is expected"); }//from ww w . j a va 2 s. c o m delimiter = value.charAt(0); } OfflineAttributesFilter stateAttrFilter = OfflineAttributesFilter.ALL; if (line.hasOption("attributes-filter")) { stateAttrFilter = OfflineAttributesFilter.valueOf(line.getOptionValue("attributes-filter")); } boolean addSampleColumn = line.hasOption("add-sample-column"); boolean keepAllSamples = line.hasOption("keep-all-samples"); try (Writer writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) { offlineDb.exportCsv(workflowId, writer, new OfflineDbCsvExportConfig(delimiter, stateAttrFilter, addSampleColumn, keepAllSamples)); } }
From source file:com.joyent.manta.client.MantaObjectOutputStreamIT.java
public void canUploadSmallString() throws IOException { String path = testPathPrefix + "uploaded-" + UUID.randomUUID() + ".txt"; MantaObjectOutputStream out = mantaClient.putAsOutputStream(path); try {/*from w w w.j av a 2s.c o m*/ out.write(TEST_DATA.getBytes(StandardCharsets.UTF_8)); } finally { out.close(); } MantaObject uploaded = out.getObjectResponse(); Assert.assertEquals(uploaded.getContentLength().longValue(), TEST_DATA.length(), "Uploaded content length doesn't match"); Assert.assertTrue(mantaClient.existsAndIsAccessible(path), "File wasn't uploaded: " + path); String actual = mantaClient.getAsString(path); Assert.assertEquals(actual, TEST_DATA, "Uploaded bytes don't match"); }
From source file:com.lexicalintelligence.admin.remove.RemoveRequest.java
public RemoveResponse execute() { List<BasicNameValuePair> params = Collections .singletonList(new BasicNameValuePair(getName(), StringUtils.join(items, ","))); RemoveResponse removeResponse;/*from w w w . j a v a 2 s . c o m*/ Reader reader = null; try { HttpResponse response = client.getHttpClient().execute(new HttpGet(client.getUrl() + PATH + getPath() + "?" + URLEncodedUtils.format(params, StandardCharsets.UTF_8))); reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8); removeResponse = new RemoveResponse(Boolean.valueOf(IOUtils.toString(reader))); } catch (Exception e) { removeResponse = new RemoveResponse(false); log.error(e); } finally { try { reader.close(); } catch (Exception e) { log.error(e); } } return removeResponse; }
From source file:net.morimekta.idltool.IdlUtils.java
private static File getCacheDirectory(File cacheDir, String repository) throws IOException { if (!cacheDir.exists()) { if (!cacheDir.mkdirs()) { throw new IOException( "Unable to create cache directory " + cacheDir.getCanonicalFile().getAbsolutePath()); }/* w w w . java 2 s . com*/ } String hash = Base64.getUrlEncoder() .encodeToString(DigestUtils.sha1(repository.getBytes(StandardCharsets.UTF_8))); return new File(cacheDir, hash).getCanonicalFile().getAbsoluteFile(); }
From source file:com.jivesoftware.os.amza.api.partition.PartitionName.java
public static String toHumanReadableString(PartitionName partitionName) { if (Arrays.equals(partitionName.getRingName(), partitionName.getName())) { return new String(partitionName.getRingName(), StandardCharsets.UTF_8) + "::.."; } else {// w w w . java 2 s. co m return new String(partitionName.getRingName(), StandardCharsets.UTF_8) + "::" + new String(partitionName.getName(), StandardCharsets.UTF_8); } }
From source file:org.opendaylight.alto.manager.AltoManager.java
protected String readFromFile(String path) throws IOException { return new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); }
From source file:com.arrow.acs.ApiRequestSigner.java
public ApiRequestSigner parameter(String name, String value) { Validate.notEmpty(name, "name is empty"); try {// w w w .ja v a 2 s. c o m parameters.add( String.format("%s=%s", URLEncoder.encode(name.toLowerCase(), StandardCharsets.UTF_8.toString()), StringUtils.trimToEmpty(value))); } catch (Exception e) { throw new AcsSystemException("system error", e); } return this; }
From source file:com.google.gitiles.doc.TocFormatter.java
String idFromHeader(HeaderNode header) { String id = ids.get(header);/*from ww w. j av a 2s .c o m*/ if (id == null) { String title = MarkdownUtil.getInnerText(header); if (title == null) { return null; } id = idFromTitle(title); if (ids.values().contains(id)) { id = String.format("%s-%x", id, Hashing.md5().hashString(id, StandardCharsets.UTF_8).asInt()); } ids.put(header, id); } return id; }
From source file:feign.httpclient.ApacheHttpClientTest.java
@Test public void queryParamsAreRespectedWhenBodyIsEmpty() throws InterruptedException { final HttpClient httpClient = HttpClientBuilder.create().build(); final JaxRsTestInterface testInterface = Feign.builder().contract(new JAXRSContract()) .client(new ApacheHttpClient(httpClient)) .target(JaxRsTestInterface.class, "http://localhost:" + server.getPort()); server.enqueue(new MockResponse().setBody("foo")); server.enqueue(new MockResponse().setBody("foo")); assertEquals("foo", testInterface.withBody("foo", "bar")); final RecordedRequest request1 = server.takeRequest(); assertEquals("/withBody?foo=foo", request1.getPath()); assertEquals("bar", request1.getBody().readString(StandardCharsets.UTF_8)); assertEquals("foo", testInterface.withoutBody("foo")); final RecordedRequest request2 = server.takeRequest(); assertEquals("/withoutBody?foo=foo", request2.getPath()); assertEquals("", request2.getBody().readString(StandardCharsets.UTF_8)); }