public class LogScanner extends Object implements Iterator<LogEntry>, Iterable<LogEntry>
LogReader
class)Constructor and Description |
---|
LogScanner(File file)
Create a LogScanner that reads access log data from the given
file.
|
LogScanner(Scanner inStream)
Create a LogScanner that reads access log data from the given
stream.
|
LogScanner(String file)
Create a LogScanner that reads access log data from the given
file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreEntries()
|
boolean |
hasNext()
Does the scanner have more data to supply?
|
Iterator<LogEntry> |
iterator()
Return this object, unchanged, to provide support for foreach-style
loops.
|
LogEntry |
next()
Analyze the next line from the log file and
make it available via a LogEntry object.
|
LogEntry |
nextEntry()
|
void |
remove()
Provided for compliance with the
Iterator interface,
but this method is not supported. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
forEach, spliterator
public LogScanner(String file)
file
- The name of the file to openpublic LogScanner(File file)
file
- The file to openpublic LogScanner(Scanner inStream)
inStream
- The stream to read frompublic boolean hasNext()
public LogEntry next()
next
in interface Iterator<LogEntry>
NoSuchElementException
- if there are no more log entries
(call hasNext()
first if you want to avoid the exception)public void remove()
Iterator
interface,
but this method is not supported.remove
in interface Iterator<LogEntry>
UnsupportedOperationException
- if you call it, since
this operation is not supported on LogScannerspublic Iterator<LogEntry> iterator()
Scanner
(possibly attached to a file) that
was used to create this LogScanner.public boolean hasMoreEntries()
hasNext()
provided for backward
compatibility with the older Java 1.4-style LogReader
class.public LogEntry nextEntry()
hasNext()
provided for backward
compatibility with the older Java 1.4-style LogReader
class. This one silently converts NoSuchElementExceptions
into null return values for backward compatibility.