List of usage examples for com.google.common.io CharStreams toString
public static String toString(Readable r) throws IOException
From source file:com.eincs.decanter.utils.io.StringResponseHandler.java
@Override public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException { return CharStreams.toString(new InputStreamReader(response.getEntity().getContent())); }
From source file:com.devbliss.doctest.renderer.html.HtmlItems.java
private static String getCss() { try {/*from w ww. j a va 2 s . c o m*/ InputStream htmlCSSStream = HtmlItems.class.getResourceAsStream(HTML_STYLE_CLASSPATH_LOCATION); return CharStreams.toString(new InputStreamReader(htmlCSSStream)); } catch (IOException e) { return "no css"; } }
From source file:com.insightml.utils.io.IoUtils.java
public static String readFile(final InputStream stream, final Charset charset) { try (InputStreamReader reader = new InputStreamReader(stream, charset)) { return CharStreams.toString(reader); } catch (final IOException e) { throw new IllegalArgumentException(e); }//from w w w.j a v a2 s . co m }
From source file:org.eclipse.scada.utils.pkg.deb.TextFileContentProvider.java
public TextFileContentProvider(final File file) throws FileNotFoundException, IOException { try (FileReader reader = new FileReader(file)) { if (file != null) { String data = CharStreams.toString(reader); if (needFix()) { data = fix(data);//from www . j a va2 s .com } this.data = data.getBytes(StandardCharsets.UTF_8); } else { this.data = null; } } }
From source file:org.sonatype.nexus.repository.maven.internal.DigestExtractor.java
/** * Extract the digest string from a stream, that carries a payload of a Maven sha1/md5 file. Method closes the * passed in stream even in case of IO problem. * * @see {@link #extract(String)}/*from w ww . j a v a 2s .c o m*/ */ @Nullable public static String extract(final InputStream stream) throws IOException { checkNotNull(stream); try (InputStreamReader isr = new InputStreamReader(new LimitedInputStream(stream, 0, MAX_CHARS_NEEDED), Charsets.UTF_8)) { return extract(CharStreams.toString(isr)); } finally { stream.close(); } }
From source file:org.cicomponents.core.OutputServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); InputStream resourceAsStream = getClass().getResourceAsStream("output.html"); String s = CharStreams.toString(new InputStreamReader(resourceAsStream)); resp.getWriter().write(s);// ww w. j a v a 2 s . c om }
From source file:com.palantir.atlasdb.versions.AtlasDbVersion.java
public static String readVersion() { try (InputStream is = AtlasDbVersion.class.getResourceAsStream(VERSION_INFO_FILE)) { if (is == null) { return VERSION_UNKNOWN_STRING; }/*w w w. j a v a 2s .c o m*/ return CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8)).trim(); } catch (IOException e) { return VERSION_UNKNOWN_STRING; } }
From source file:cuchaz.enigma.Util.java
public static String readStreamToString(InputStream in) throws IOException { return CharStreams.toString(new InputStreamReader(in, "UTF-8")); }
From source file:org.auraframework.ds.util.BundleResourceLoaderImpl.java
private static String inputStreamToString(InputStream inputStream) throws IOException { if (inputStream == null) { return null; }//w w w . j a v a 2 s. c o m try { return CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8)); } catch (UnsupportedEncodingException e) { // This is extremely unlikely return CharStreams.toString(new InputStreamReader(inputStream)); } finally { inputStream.close(); } }
From source file:org.eclipse.viatra.query.tooling.ui.migrator.FileStringReplacer.java
public FileStringReplacer(IFile file) throws IOException, CoreException { this.file = file; try (InputStream input = file.getContents()) { this.data = CharStreams.toString(new InputStreamReader(input, Charsets.UTF_8)); }/* w w w .j a v a2 s . c o m*/ }