Package org.apache.commons.io

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


        this.processHeaderLines(aBuffer, lines);

        int lineNumber = 1;
        while (lines.hasNext()) {
            String lineText = lines.nextLine();
            aBuffer.append(XML_OPEN + this.lineElementname);

            if (this.insertLineNumbers || this.insertRawData) {
                if (this.insertLineNumbers) {
                    aBuffer.append(" number=\"");
View Full Code Here


        List<String> lines = new ArrayList<String>();
        File file = new File(filename);
        LineIterator it = FileUtils.lineIterator(file, encoding);
        try {
            while (it.hasNext()) {
                String line = it.nextLine();
                lines.add(line);
            }
        } finally {
            it.close();
        }
View Full Code Here

      // We want to grab the files called .out
      if (file.getName().contains(".out") && file.isFile() && file.canRead()) {
        LineIterator it = FileUtils.lineIterator(file, Constants.UTF8.name());
        try {
          while (it.hasNext()) {
            String line = it.nextLine();
            if (line.matches(".* \\[" + AuditedSecurityOperation.AUDITLOG + "\\s*\\].*")) {
              // Only include the message if startTimestamp is null. or the message occurred after the startTimestamp value
              if ((lastAuditTimestamp == null) || (line.substring(0, 23).compareTo(lastAuditTimestamp) > 0))
                result.add(line);
            }
View Full Code Here

    // Just grab the first rf file, it will do for now.
    String filePrefix = "file:";
    try {
      while (it.hasNext() && importFile == null) {
        String line = it.nextLine();
        if (line.matches(".*\\.rf")) {
          importFile = new File(line.replaceFirst(filePrefix, ""));
        }
      }
    } finally {
View Full Code Here

            doSleep();
            System.exit(0);
        } else if (READ_INPUT_LINES_AND_PRINT_THEM.equals(args[0])) {
            LineIterator iterator = IOUtils.lineIterator(System.in, "UTF-8");
            while (iterator.hasNext()) {
                String line = iterator.nextLine();
                System.out.println(line);

            }
        } else {
            System.out.println(args[0]);
View Full Code Here

    NewLineReader r = new NewLineReader(new StringReader(inputString));
    LineIterator i = r.iterateLines();
   
    Assert.assertTrue(i.hasNext());
    Assert.assertEquals(i.nextLine(), inputString);
    Assert.assertFalse(i.hasNext());
    Assert.assertNull(r.getInputNewLine());
    Assert.assertNull(r.getOutputNewLine());
    // Test the actual output
    r.reset();
View Full Code Here

    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

            doSleep();
            System.exit(0);
        } else if (READ_INPUT_LINES_AND_PRINT_THEM.equals(args[0])) {
            LineIterator iterator = IOUtils.lineIterator(System.in, "UTF-8");
            while (iterator.hasNext()) {
                String line = iterator.nextLine();
                System.out.println(line);

            }
        } else {
            System.out.println(args[0]);
View Full Code Here

      throw new IOException( "Resource \"" + RESOURCE_NAME_DE_PLZ_TXT + "\" not found" );
    }

    LineIterator iterator = IOUtils.lineIterator( resource.openStream(), "UTF-8" );
    while ( iterator.hasNext() ) {
      String line = iterator.nextLine();
      String[] parts = line.split( "\t" );
      if ( parts.length < 2 ) {
        continue;
      }
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.