Package org.apache.commons.io

Examples of org.apache.commons.io.LineIterator


        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
        InputStream instream = new FileInputStream(this.tmpfile);
        try {
            LineIterator it = IOUtils.lineIterator(instream, ASCII.name());
            int count = 0;
            while (it.hasNext()) {
                String line = it.next();
                int i = count % TEXT.length;
                String expected = TEXT[i];
                Assert.assertEquals(expected, line);
                count++;
            }
View Full Code Here


        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
        InputStream instream = new FileInputStream(this.tmpfile);
        try {
            LineIterator it = IOUtils.lineIterator(instream, ASCII.name());
            int count = 0;
            while (it.hasNext()) {
                String line = it.next();
                int i = count % TEXT.length;
                String expected = TEXT[i];
                Assert.assertEquals(expected, line);
                count++;
            }
View Full Code Here

                ContentType contentType = ContentType.getOrDefault(requestEntity);
                Charset charset = contentType.getCharset();
                if (charset == null) {
                    charset = Consts.ISO_8859_1;
                }
                LineIterator it = IOUtils.lineIterator(instream, charset.name());
                int count = 0;
                while (it.hasNext()) {
                    String line = it.next();
                    int i = count % TEXT.length;
                    String expected = TEXT[i];
                    if (!line.equals(expected)) {
                        ok = false;
                        break;
View Full Code Here

     * @throws org.openrdf.rio.RDFHandlerException If the configured statement handler has encountered an
     *                                             unrecoverable error.
     */
    @Override
    public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
        LineIterator it = IOUtils.lineIterator(in, RDFFormat.RDFXML.getCharset());
        try {
            while(it.hasNext()) {
                lineNumber++;

                String line = it.nextLine();
                if(lineNumber % 2 == 0) {
                    // only odd line numbers contain triples
                    StringReader buffer = new StringReader(line);
                    lineParser.parse(buffer, baseURI);
                }
            }
        } finally {
            it.close();
        }
    }
View Full Code Here

     * @throws org.openrdf.rio.RDFHandlerException If the configured statement handler has encountered an
     *                                             unrecoverable error.
     */
    @Override
    public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
        LineIterator it = IOUtils.lineIterator(reader);
        try {
            while(it.hasNext()) {
                lineNumber++;

                String line = it.nextLine();
                if(lineNumber % 2 == 1) {
                    // only odd line numbers contain triples
                    StringReader buffer = new StringReader(line);
                    lineParser.parse(buffer, baseURI);
                }
            }
        } finally {
            it.close();
        }
    }
View Full Code Here

                @Override
                public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
                    if (200 == response.getStatusLine().getStatusCode()) {
                        HttpEntity entity = response.getEntity();

                        final LineIterator it = IOUtils.lineIterator(entity.getContent(), Charset.defaultCharset());
                        try {
                            while (it.hasNext()) {
                                final String l = it.next();
                                if (l.startsWith(prefix + "\t")) {
                                    return l.substring(prefix.length()+1);
                                }
                            }
                        } finally {
                            it.close();
                        }
                    }
                    log.error("Error: prefix '" + prefix + "' not found at prefix.cc");
                    return null;
                }
View Full Code Here

                @Override
                public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
                    if (200 == response.getStatusLine().getStatusCode()) {
                        HttpEntity entity = response.getEntity();

                        final LineIterator it = IOUtils.lineIterator(entity.getContent(), Charset.defaultCharset());
                        try {
                            while (it.hasNext()) {
                                final String l = it.next();
                                if (l.endsWith("\t" + namespace)) {
                                    return l.substring(0, l.indexOf("\t"));
                                }
                            }
                        } finally {
                            it.close();
                        }
                    }
                    log.error("Error: reverse namespace lookup for '" + namespace + "' not found at prefix.cc");
                    return null;
                }
View Full Code Here

        state = State.SWEEPING;
        LOG.debug("Starting sweep phase of the garbage collector");

        ConcurrentLinkedQueue<String> exceptionQueue = new ConcurrentLinkedQueue<String>();

        LineIterator iterator =
                FileUtils.lineIterator(fs.getGcCandidates(), Charsets.UTF_8.name());
        List<String> ids = Lists.newArrayList();

        while (iterator.hasNext()) {
            ids.add(iterator.next());

            if (ids.size() > getBatchCount()) {
                count += ids.size();
                executor.execute(new Sweeper(ids, exceptionQueue));
                ids = Lists.newArrayList();
View Full Code Here

    }
   
    private List<String> getExampleBenchmarkPaths(HttpServletRequest request) throws IOException {
        // TODO how to enumerate bundle resources?
        final String list = getBenchmarkText("/LIST.txt");
        final LineIterator it = new LineIterator(new StringReader(list));
        final List<String> result = new LinkedList<String>();
        while(it.hasNext()) {
            result.add(getExampleBenchmarkPath(request, it.nextLine()));
        }
        return result;
    }
View Full Code Here

    ClientResponse response = dockerClient.build(baseDir);

    StringWriter logwriter = new StringWriter();

    try {
      LineIterator itr = IOUtils.lineIterator(
          response.getEntityInputStream(), "UTF-8");
      while (itr.hasNext()) {
        String line = itr.next();
        logwriter.write(line + "\n");
        LOG.info(line);
      }
    } finally {
      IOUtils.closeQuietly(response.getEntityInputStream());
View Full Code Here

TOP

Related Classes of org.apache.commons.io.LineIterator

Copyright © 2018 www.massapicom. 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.