Refine search
@NotNull private static String read(@NotNull InputStream stream) throws IOException { return CharStreams.toString(new InputStreamReader(stream)); } }
public String getContent(String charset) { if(charset == null) { return content; } try { return CharStreams.toString(new InputStreamReader(raw, charset)); } catch (Exception e) { e.printStackTrace(); return content; } }
public static String readFile(Path path) throws IOException { try (InputStream in = Files.newInputStream(path)) { return CharStreams.toString(new InputStreamReader(in, UTF_8)); } }
private String text(final InputStream stream) { try (InputStream in = stream) { return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (IOException | NullPointerException x) { throw new NoSuchElementException(); } } }
private String message(final Response response) { final Readable reader; try { reader = new InputStreamReader(response.readEntity(InputStream.class), UTF_8); } catch (IllegalStateException e) { return null; } try { return CharStreams.toString(reader); } catch (IOException ignore) { return null; } }
private static String exec(final String command) { try { final Process process = Runtime.getRuntime().exec(command); return CharStreams.toString(new InputStreamReader(process.getInputStream(), UTF_8)); } catch (IOException e) { throw new RuntimeException(e); } }
private String exec(final String command) { try { final Process process = Runtime.getRuntime().exec(command); return CharStreams.toString(new InputStreamReader(process.getInputStream(), UTF_8)); } catch (IOException e) { throw new RuntimeException(e); } } }
public static String readResource(String name) { try (InputStream in = Resources.getResource(name).openStream()) { return CharStreams.toString(new InputStreamReader(in, UTF_8)); } catch (IOException ex) { throw new RuntimeException(ex); } }
InputStreamReader esr = null; try { isr = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8); CharStreams.toString(isr); } catch (IOException e) { InputStream errorStream = conn.getErrorStream(); esr = new InputStreamReader(errorStream, StandardCharsets.UTF_8); try { CharStreams.toString(esr); } catch (IOException ioe) {
private String getGitConfig(final String configName, final String defaultValue) { try { final Process process = new ProcessBuilder("git", "config", configName).redirectErrorStream(true).start(); return CharStreams.toString(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)).trim(); } catch (Throwable ex) { return "YOUR_NAME"; } }
private String readInput(AssetDataFile input) throws IOException { try (InputStreamReader reader = new InputStreamReader(input.openStream(), Charsets.UTF_8)) { return CharStreams.toString(reader); } }
public Builder loadSource(InputStream srcStream, Charset encoding) throws IOException { String src = CharStreams.toString(new InputStreamReader(srcStream, encoding)); createPayload(src); return this; }
protected final String sendPostRequest(String request) throws IOException { URL url = new URL("http", DEFAULT_HOST, this.port, request); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("POST"); con.setDoOutput(true); OutputStream out = con.getOutputStream(); out.write("".getBytes()); out.flush(); InputStream in = con.getInputStream(); String response = CharStreams.toString(new InputStreamReader(con.getInputStream())); in.close(); return response; }
@Benchmark public String guavaCharStreams() throws IOException { mark(); String result = CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8)); inputStream.reset(); return result; }
@Benchmark public String test2_guavaCharStreams() throws IOException { mark(); String result = CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8)); inputStream.reset(); return result; }
private ImmutableSortedMap<String, ImmutableList<String>> readMap(final String mapPath) { String fileContent; String actualPath = mapPath; try { if (Strings.isNullOrEmpty(mapPath)) { actualPath = this.getClass().getClassLoader().getResource("defaultWhiteListMap.json").getFile(); LOGGER.info("using default whiteList map located at [%s]", actualPath); InputStream byteContent = this.getClass().getClassLoader().getResourceAsStream("defaultWhiteListMap.json"); fileContent = CharStreams.toString(new InputStreamReader(byteContent, StandardCharsets.UTF_8)); } else { fileContent = Files.asCharSource(new File(mapPath), StandardCharsets.UTF_8).read(); } return mapper.readerFor(new TypeReference<ImmutableSortedMap<String, ImmutableList<String>>>() { }).readValue(fileContent); } catch (IOException e) { throw new ISE(e, "Got an exception while parsing file [%s]", actualPath); } }
public static String readString(InputStream is) throws IOException { return CharStreams.toString(new InputStreamReader(is, "UTF-8")); }
new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) { error = CharStreams.toString(stderr); new InputStreamReader(dockerProcess.getInputStream(), StandardCharsets.UTF_8)) { String output = CharStreams.toString(stdout); new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) { throw new IOException( "'docker load' command failed with output: " + CharStreams.toString(stderr));
private static String readSchema(String dataSchemaLocation) { InputStream inputStream = null; try { if (isURI(dataSchemaLocation.trim().toLowerCase(ENGLISH))) { try { inputStream = new URL(dataSchemaLocation).openStream(); } catch (MalformedURLException e) { // try again before failing inputStream = new FileInputStream(dataSchemaLocation); } } else { inputStream = new FileInputStream(dataSchemaLocation); } return CharStreams.toString(new InputStreamReader(inputStream, UTF_8)); } catch (IOException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, "Could not parse the Avro schema at: " + dataSchemaLocation, e); } finally { closeQuietly(inputStream); } }
@Override public String call() throws Exception { return CharStreams.toString(new InputStreamReader(stream)); } });