Package java.io

Examples of java.io.BufferedReader.lines()


    @Override
    public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
                                         final Function<DetachedVertex, Vertex> vertexMaker,
                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
        return br.lines().<Vertex>map(FunctionUtils.wrapFunction(line -> readVertex(new ByteArrayInputStream(line.getBytes()), direction, vertexMaker, edgeMaker))).iterator();
    }

    @Override
    public Edge readEdge(final InputStream inputStream, final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
        final Map<String, Object> edgeData = mapper.readValue(inputStream, mapTypeReference);
View Full Code Here


     * @since   1.8
     */
    public static Stream<String> lines(Path path, Charset cs) throws IOException {
        BufferedReader br = Files.newBufferedReader(path, cs);
        try {
            return br.lines().onClose(asUncheckedRunnable(br));
        } catch (Error|RuntimeException e) {
            try {
                br.close();
            } catch (IOException ex) {
                try {
View Full Code Here

     * Converts input stream to String containing lines separated by \n
     */
    private String readStream(final InputStream stream)  {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
        final StringJoiner builder = new StringJoiner("\n");
        reader.lines().forEach(builder::add);
        return builder.toString();
    }
}
View Full Code Here

    writer.close();

    BufferedReader reader = Files.newBufferedReader(tempFile, StandardCharsets.UTF_8);
    // BufferedReader.lines() returns a stream containing lines in the Reader, these are only (lazily) read when the
    // terminal operation of the stream is executed - e.g. collect()
    List<String> readPhrase = reader.lines().collect(Collectors.toList());
    reader.close();

    assertThat(readPhrase, is(Arrays.asList(phrase)));
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.