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:fi.johannes.kata.ocr.utils.files.CFileOperations.java
public static String fileContentToString(String filepath) throws IOException { Path p = Paths.get(filepath); byte[] contents = Files.readAllBytes(p); return new String(contents, StandardCharsets.UTF_8); }
From source file:com.ibm.streamsx.topology.internal.streaminganalytics.RestUtils.java
public static String getJobSubmitURL(JsonObject credentials, File bundle) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(500); sb.append(jstring(credentials, "rest_url")); sb.append(jstring(credentials, "jobs_path")); sb.append("?"); sb.append("bundle_id="); sb.append(URLEncoder.encode(bundle.getName(), StandardCharsets.UTF_8.name())); return sb.toString(); }
From source file:org.pentaho.di.core.util.HttpClientUtil.java
/** * * @param response the httpresponse for processing * @return HttpEntity in String representation using "UTF-8" encoding * @throws IOException//www. j a va 2s. c om */ public static String responseToString(HttpResponse response) throws IOException { return responseToString(response, Charset.forName(StandardCharsets.UTF_8.name())); }
From source file:com.github.aistomin.xml.XmlResource.java
@Override public String content() throws Exception { return IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream(this.name), StandardCharsets.UTF_8); }
From source file:Main.java
public static InputStream streamify(String xml) { return new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); }
From source file:com.thoughtworks.go.server.JettyCustomErrorPageHandler.java
public JettyCustomErrorPageHandler() throws IOException { try (InputStream in = getClass().getResourceAsStream("/error.html")) { fileContents = IOUtils.toString(in, StandardCharsets.UTF_8); }// w w w . ja v a 2s .c o m }
From source file:com.sonarsource.lits.Dump.java
static void load(File file, Map<String, Multiset<IssueKey>> result) { JSONObject json;/*from w w w . j av a 2 s .co m*/ try (FileInputStream fis = new FileInputStream(file); InputStreamReader in = new InputStreamReader(fis, StandardCharsets.UTF_8)) { json = (JSONObject) JSONValue.parse(in); } catch (IOException e) { throw Throwables.propagate(e); } String ruleKey = ruleKeyFromFileName(file.getName()); for (Map.Entry<String, Object> component : json.entrySet()) { String componentKey = component.getKey(); Multiset<IssueKey> issues = result.get(componentKey); if (issues == null) { issues = HashMultiset.create(); result.put(componentKey, issues); } JSONArray lines = (JSONArray) component.getValue(); for (Object line : lines) { issues.add(new IssueKey(componentKey, ruleKey, (Integer) line)); } } }
From source file:com.thoughtworks.go.util.XpathUtils.java
public static boolean nodeExists(String xmlPartial, String xpath) throws XPathExpressionException { return nodeExists(new ByteArrayInputStream(xmlPartial.getBytes(StandardCharsets.UTF_8)), xpath); }
From source file:io.syndesis.rest.v1.handler.exception.HttpClientErrorExceptionMapper.java
@Override public Response toResponse(HttpClientErrorException exception) { RestError error = new RestError(exception.getMessage(), exception.getMessage(), ErrorMap.from(new String(exception.getResponseBodyAsByteArray(), StandardCharsets.UTF_8)), exception.getStatusCode().value()); return Response.status(exception.getStatusCode().value()).type(MediaType.APPLICATION_JSON_TYPE) .entity(error).build();/*from w w w .ja v a2s . c o m*/ }
From source file:io.syndesis.rest.v1.handler.exception.HttpServerErrorExceptionMapper.java
@Override public Response toResponse(HttpServerErrorException exception) { RestError error = new RestError(exception.getMessage(), exception.getMessage(), ErrorMap.from(new String(exception.getResponseBodyAsByteArray(), StandardCharsets.UTF_8)), exception.getStatusCode().value()); return Response.status(exception.getStatusCode().value()).type(MediaType.APPLICATION_JSON_TYPE) .entity(error).build();/*from ww w . j a va2 s . co m*/ }