|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavatools.datatypes.PeekIterator<java.lang.String>
javatools.filehandlers.FileLines
public class FileLines
This class is part of the Java Tools (see
http://mpii.de/yago-naga/javatools). It is licensed under the Creative
Commons Attribution License (see http://creativecommons.org/licenses/by/3.0)
by the YAGO-NAGA team (see http://mpii.de/yago-naga).
The class provides an iterator over the lines in a file
Example:
for (String s : new FileLines("c:\\autoexec.bat")) { System.out.println(s); }If desired, the iterator can make a nice progress bar by calling Announce.progressStart/At/Done automatically in the right order. If there are no more lines, the file is closed. If you do not use all lines of the iterator, close the iterator manually.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javatools.datatypes.PeekIterator |
---|
PeekIterator.ElementaryPeekIterator<T>, PeekIterator.SimplePeekIterator<T> |
Field Summary | |
---|---|
static long |
maxChars
Maximum chars to read by readTo (or -1) |
Fields inherited from class javatools.datatypes.PeekIterator |
---|
closed, initialized, next |
Constructor Summary | |
---|---|
FileLines(java.io.BufferedReader r)
Constructs FileLines from a BufferedReader (main constructor 3) |
|
FileLines(java.io.File f)
Constructs FileLines from a file |
|
FileLines(java.io.File f,
java.lang.String announceMsg)
Constructs FileLines from a file, shows progress bar (main constructor 2) |
|
FileLines(java.io.File f,
java.lang.String encoding,
java.lang.String announceMsg)
Constructs FileLines from a file with an encoding, shows progress bar (main constructor 1) |
|
FileLines(java.io.Reader f)
Constructs FileLines from a Reader |
|
FileLines(java.lang.String f)
Constructs FileLines from a filename |
|
FileLines(java.lang.String f,
java.lang.String announceMsg)
Constructs FileLines from a filename, shows progress bar |
|
FileLines(java.lang.String f,
java.lang.String encoding,
java.lang.String announceMsg)
Constructs FileLines from a filename with a given encoding, shows progress bar |
Method Summary | |
---|---|
void |
close()
Closes the reader |
void |
finalize()
Closes the reader |
static int |
find(java.io.Reader in,
java.lang.String... findMe)
Reads until one of the strings is found, returns its index or -1. |
static int |
find(java.io.Reader in,
java.lang.StringBuilder b,
java.lang.String... findMe)
Reads until one of the strings is found, returns its index or -1. |
static int |
findIgnoreCase(java.io.Reader in,
java.lang.String... findMe)
Reads until one of the strings is found, returns its index or -1. |
static int |
firstCharAfterSpace(java.io.Reader in)
Skips space |
java.lang.String |
internalNext()
Returns next line. |
java.util.Iterator<java.lang.String> |
iterator()
Returns this |
static int |
numAllFileLines(java.io.File f,
java.lang.String ext)
returns number of lines in file |
static int |
numFileLines(java.io.File f)
returns number of lines in file |
static java.lang.String |
readBetween(java.io.Reader in,
java.lang.String start,
java.lang.String end)
Reads the string between the delimiters |
static java.lang.String |
readBetween(java.lang.String in,
java.lang.String start,
java.lang.String end)
Reads the string between the delimiters |
static java.lang.CharSequence |
readTo(java.io.Reader in,
char... limit)
Reads to a specific character, returns the text in between |
static java.lang.CharSequence |
readTo(java.io.Reader in,
char limit)
Reads to a specific character, returns the text in between |
static java.lang.CharSequence |
readTo(java.io.Reader in,
java.lang.String limit)
Reads to a specific String, returns the text up to there, including the limit |
static java.lang.CharSequence |
readTo(java.io.Reader in,
java.lang.String limit,
java.util.List<java.lang.Integer> results)
Reads to a specific String, returns the text up to there, including the limit |
static java.lang.String |
readToBoundary(java.io.Reader in,
java.lang.String limit)
Reads to a specific string, returns text up to there, without boundary or returns NULL |
static java.lang.CharSequence |
readToSpace(java.io.Reader in)
Reads to a whitespace |
void |
remove()
Unsupported, throws an UnsupportedOperationException |
static boolean |
scrollTo(java.io.Reader in,
char... delimiters)
Scrolls to one of the characters |
static boolean |
scrollTo(java.io.Reader in,
char delimiter)
Reads to a specific character |
static boolean |
scrollTo(java.io.Reader in,
java.lang.String limit)
Scrolls to a specific limit and beyond |
java.lang.String |
toString()
Returns a simple identifier |
Methods inherited from class javatools.datatypes.PeekIterator |
---|
asList, asList, asSet, asSet, asSet, emptyIterator, hasNext, list, list, main, next, nextOrNull, numElements, numElements, peek, toString, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Iterator |
---|
hasNext, next |
Field Detail |
---|
public static long maxChars
Constructor Detail |
---|
public FileLines(java.lang.String f) throws java.io.IOException
java.io.IOException
public FileLines(java.io.File f) throws java.io.IOException
java.io.IOException
public FileLines(java.lang.String f, java.lang.String announceMsg) throws java.io.IOException
java.io.IOException
public FileLines(java.lang.String f, java.lang.String encoding, java.lang.String announceMsg) throws java.io.IOException
java.io.IOException
public FileLines(java.io.File f, java.lang.String encoding, java.lang.String announceMsg) throws java.io.IOException
java.io.IOException
public FileLines(java.io.File f, java.lang.String announceMsg) throws java.io.IOException
java.io.IOException
public FileLines(java.io.Reader f)
public FileLines(java.io.BufferedReader r)
Method Detail |
---|
public void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator<java.lang.String>
remove
in class PeekIterator<java.lang.String>
java.lang.UnsupportedOperationException
public java.lang.String internalNext()
public java.lang.String toString()
toString
in class PeekIterator<java.lang.String>
public java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
iterator
in class PeekIterator<java.lang.String>
public void close()
close
in interface java.io.Closeable
close
in class PeekIterator<java.lang.String>
public void finalize()
finalize
in class java.lang.Object
public static int find(java.io.Reader in, java.lang.String... findMe) throws java.io.IOException
java.io.IOException
public static int find(java.io.Reader in, java.lang.StringBuilder b, java.lang.String... findMe) throws java.io.IOException
java.io.IOException
public static int findIgnoreCase(java.io.Reader in, java.lang.String... findMe) throws java.io.IOException
java.io.IOException
public static java.lang.CharSequence readTo(java.io.Reader in, char... limit) throws java.io.IOException
java.io.IOException
public static java.lang.CharSequence readToSpace(java.io.Reader in) throws java.io.IOException
java.io.IOException
public static int firstCharAfterSpace(java.io.Reader in) throws java.io.IOException
java.io.IOException
public static java.lang.CharSequence readTo(java.io.Reader in, char limit) throws java.io.IOException
java.io.IOException
public static java.lang.CharSequence readTo(java.io.Reader in, java.lang.String limit) throws java.io.IOException
java.io.IOException
public static java.lang.String readToBoundary(java.io.Reader in, java.lang.String limit) throws java.io.IOException
java.io.IOException
public static boolean scrollTo(java.io.Reader in, char... delimiters) throws java.io.IOException
java.io.IOException
public static boolean scrollTo(java.io.Reader in, char delimiter) throws java.io.IOException
java.io.IOException
public static boolean scrollTo(java.io.Reader in, java.lang.String limit) throws java.io.IOException
java.io.IOException
public static java.lang.String readBetween(java.io.Reader in, java.lang.String start, java.lang.String end) throws java.io.IOException
java.io.IOException
public static java.lang.String readBetween(java.lang.String in, java.lang.String start, java.lang.String end)
java.io.IOException
public static java.lang.CharSequence readTo(java.io.Reader in, java.lang.String limit, java.util.List<java.lang.Integer> results) throws java.io.IOException
java.io.IOException
public static int numFileLines(java.io.File f) throws java.io.IOException
java.io.IOException
public static int numAllFileLines(java.io.File f, java.lang.String ext) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |