List of usage examples for com.google.common.io CharStreams toString
public static String toString(Readable r) throws IOException
From source file:com.orange.clara.cloud.servicedbdumper.fake.filer.EchoFiler.java
@Override public void store(InputStream inputStream, String filename) throws IOException { String echoed = CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8)); this.lastTextInStream = echoed; logger.info("Echo filer stored: " + echoed); inputStream.close();// w ww. jav a 2 s. c om }
From source file:br.com.objectos.jabuticava.debs.Caracteristica.java
public static Caracteristica wget() { try {/*from w ww.j av a 2s . c om*/ URLReaderSupplier in = new URLReaderSupplier(url); Reader reader = in.getReader(CHARSET); String text = CharStreams.toString(reader); return Caracteristica.parseString(text); } catch (IOException e) { return Caracteristica.vazio(); } }
From source file:org.roda.wui.common.HTMLUtils.java
public static String preservationMetadataEventToHtml(Binary binary, boolean onlyDetails, final Locale locale) throws GenericException { Map<String, String> translations = getEventTranslations(locale); Reader reader = RodaUtils.applyEventStylesheet(binary, onlyDetails, translations, RodaConstants.CROSSWALKS_DISSEMINATION_HTML_EVENT_PATH); try {//from w ww. ja v a 2 s.co m return CharStreams.toString(reader); } catch (IOException e) { throw new GenericException("Could not transform PREMIS to HTML", e); } }
From source file:io.macgyver.ssh.StringResponseCallback.java
@Override public String handle(Command cmd) throws IOException { InputStream inputStream = cmd.getInputStream(); String string = CharStreams.toString(new InputStreamReader(inputStream, "UTF-8")); cmd.join(5, TimeUnit.SECONDS); if (cmd.getExitStatus() != 0) { String x = CharStreams.toString(new InputStreamReader(cmd.getErrorStream(), "UTF-8")); throw new SshException(cmd.getExitStatus(), x); }//from www .ja v a 2 s . c om return string; }
From source file:pl.robakowski.repository.PackagistRepository.java
@Override public List<JSONObject> getNextResults(IProgressMonitor monitor) { LinkedList<JSONObject> result = new LinkedList<JSONObject>(); try {//from ww w . j a v a2 s .com InputStream input = new URL(addr).openStream(); JSONObject object = new JSONObject(CharStreams.toString(new InputStreamReader(input))); input.close(); JSONArray resultArray = object.getJSONArray("results"); for (int i = 0; i < resultArray.length(); i++) { JSONObject obj = resultArray.getJSONObject(i); result.add(obj); } addr = null; if (object.has("next")) { addr = object.getString("next"); } } catch (Exception e) { } return result; }
From source file:com.google.jenkins.plugins.credentials.oauth.JsonKey.java
public static JsonKey load(JsonFactory jsonFactory, InputStream inputStream) throws IOException { InputStreamReader reader = new InputStreamReader(inputStream, Charsets.UTF_8); try {/* w w w . j av a2s .com*/ Secret decoded = Secret.fromString(CharStreams.toString(reader)); return jsonFactory.fromString(decoded.getPlainText(), JsonKey.class); } finally { inputStream.close(); } }
From source file:com.github.projectsandstone.spongeremotechests.util.Resources.java
public static String getSqlQuery(Type type) { InputStream resourceAsStream = SpongeRemoteChestsPlugin.class.getClassLoader() .getResourceAsStream("/sql/" + type.name); String query;/*from w w w. java 2 s . c om*/ try (InputStreamReader reader = new InputStreamReader(resourceAsStream, Charsets.UTF_8)) { query = CharStreams.toString(reader); } catch (IOException e) { throw new RuntimeException(e); } return query; }
From source file:com.reprezen.swagedit.editor.SwaggerContentDescriber.java
@Override public int describe(InputStream contents, IContentDescription description) throws IOException { String content = CharStreams.toString(new InputStreamReader(contents)); if (content.trim().isEmpty()) { return INDETERMINATE; }/*from w w w.j a v a2s .c o m*/ return content.contains("swagger: \"2.0\"") || content.contains("swagger: '2.0'") ? VALID : INVALID; }
From source file:org.onosproject.cli.PrettyXml.java
@Override protected void execute() { try {//from ww w . j a v a2 s . c o m String xmlS = CharStreams.toString(new InputStreamReader(System.in)); print("%s", XmlString.prettifyXml(xmlS)); } catch (IOException e) { log.error("Failed parsing XML.", e); print("%s", e); } }
From source file:de.dentrassi.pm.deb.servlet.Helper.java
private static String loadResource(final URL url) throws IOException { try (InputStream is = url.openStream(); Reader r = new InputStreamReader(is, StandardCharsets.UTF_8)) { return CharStreams.toString(r); }/*from w ww. j a v a 2 s. c o m*/ }