tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Commons IO > Basic > Line Iterator

Line Iterator 

Apache Commons IO is a java library with simple IO utilities and filters. This requires the library commons-io-2.1.jar to be in classpath. The following example shows using FileUtils.lineIterator() API.

File Name  :  C:/Test/rule_engine_names.txt

File Name  :  
com/bethecoder/tutorials/commons_io/tests/LineIteratorTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.commons_io.tests;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;

public class LineIteratorTest {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {
    File file = new File("C:/Test/rule_engine_names.txt");
    LineIterator lineIt = FileUtils.lineIterator(file, "UTF-8");
    
    while (lineIt.hasNext()) {
      System.out.println(lineIt.next());
    }
    
    LineIterator.closeQuietly(lineIt);
  }
}
   

It gives the following output,
BizTalk
Blaze Advisor
Jess
JRules
OpenRules
PegaRules
RulesPower


                    Print

   



Books Recommendation

 
 
bl  br