Example usage for org.apache.commons.io LineIterator remove

List of usage examples for org.apache.commons.io LineIterator remove

Introduction

In this page you can find the example usage for org.apache.commons.io LineIterator remove.

Prototype

public void remove() 

Source Link

Document

Unsupported.

Usage

From source file:net.orzo.lib.Files.java

/**
 * Obtains an iterator which reads provided file (specified by path) line by
 * line. Iterator can be accessed by a classic method pair <i>hasNext()</li>
 * and <i>next()</i>.//from   w  w  w  .  j a v  a  2 s.c  om
 */
public FileIterator<Object> fileReader(final String path, final String encoding) throws IOException {
    final LineIterator itr = FileUtils.lineIterator(new File(path), encoding);
    return new FileIterator<Object>() {

        @Override
        public boolean hasNext() {
            return itr.hasNext();
        }

        @Override
        public Object next() {
            return itr.nextLine(); // TODO wrapping???
        }

        @Override
        public void remove() {
            itr.remove();
        }

        public void close() {
            itr.close();
        }

        public String getPath() {
            if (File.separator.equals("/")) {
                return path;

            } else {
                return path.replace(File.separator, "/");
            }
        }
    };
}