Package org.apache.commons.io

Examples of org.apache.commons.io.LineIterator.nextLine()


    String inputString = line1 + "\r\n" + line2;   

    NewLineReader r = new NewLineReader(new StringReader(inputString), null, "\n");
    LineIterator i = r.iterateLines();
   
    Assert.assertEquals(i.nextLine(), line1);
    Assert.assertEquals(r.getInputNewLine(), "\r\n");
    Assert.assertEquals(r.getOutputNewLine(), "\n");
    Assert.assertEquals(i.nextLine(), line2);
    Assert.assertFalse(i.hasNext()); // Should not return another line (LineIterator behavior)
   
View Full Code Here


    LineIterator i = r.iterateLines();
   
    Assert.assertEquals(i.nextLine(), line1);
    Assert.assertEquals(r.getInputNewLine(), "\r\n");
    Assert.assertEquals(r.getOutputNewLine(), "\n");
    Assert.assertEquals(i.nextLine(), line2);
    Assert.assertFalse(i.hasNext()); // Should not return another line (LineIterator behavior)
   
    // Test the actual output
    r.reset();
    String out = IOUtil.toString(r);
View Full Code Here

            }
            final Pattern p = Pattern.compile(".*" + expr + ".*");
            reader = new InputStreamReader(blob.getStream(), charset);
            final LineIterator it = new LineIterator(reader);
            while (it.hasNext()) {
                final String line = it.nextLine();
                if (p.matcher(line).matches()) {
                    continue nextPattern;
                }
            }
            fail(this + ": no match for regexp '" + expr + "', content=\n" +
View Full Code Here

        nextPattern:
        for (String expr : regexp) {
            final Pattern p = Pattern.compile(".*" + expr + ".*");
            final LineIterator it = new LineIterator(new StringReader(content));
            while (it.hasNext()) {
                final String line = it.nextLine();
                if (expected & p.matcher(line).matches()) {
                    continue nextPattern;
                }
                if(!expected & p.matcher(line).matches()) {
                    fail(this + ": match found for regexp '" + expr + "', content=\n" + content);
View Full Code Here

        // 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;
    }

    /** Return example benchmark text from our class resources */
 
View Full Code Here

        logMemory();

        final LineIterator it = FileUtils.lineIterator(new File(path), "UTF-8");
        try {
            while (it.hasNext()) {
                final String line = it.nextLine();
                // do something with line
            }
        } finally {
            LineIterator.closeQuietly(it);
        }
View Full Code Here

    } catch (IOException ex) {
      throw new OpenGammaRuntimeException("IOException when reading " + _fieldsFile, ex);
    }
    try {
      while (it.hasNext()) {
        String line = it.nextLine();
        if (StringUtils.isBlank(line) || line.charAt(0) == '#') {
          continue;
        }
        fields.add(line);
      }
View Full Code Here

    @Override
    public String detectPackageName(final InputStream stream) {
        try {
            LineIterator iterator = IOUtils.lineIterator(stream, Charset.defaultCharset());
            while (iterator.hasNext()) {
                String line = iterator.nextLine();
                Matcher matcher = pattern.matcher(line);
                if (matcher.matches()) {
                    return matcher.group(1);
                }
            }
View Full Code Here

        LineIterator lineIterator = IOUtils.lineIterator(new StringReader(highlighted));

        int line = 1;
        int offset = 1;
        while (lineIterator.hasNext()) {
            String content = lineIterator.nextLine();
            if (content.contains(LINE_6_INDICATOR)) {
                offset  = line - 6;
            }
            line++;
        }
View Full Code Here

    @Override
    public String detectPackageName(final InputStream stream) {
        try {
            LineIterator iterator = IOUtils.lineIterator(stream, "UTF-8");
            while (iterator.hasNext()) {
                String line = iterator.nextLine();
                if (line.matches("^namespace .*$")) {
                    if (line.contains("{")) {
                        return StringUtils.substringBetween(line, " ", "{").trim();
                    }
                    else {
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.