|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Reader
javatools.filehandlers.HTMLReader
public class HTMLReader
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 HTML-Reader reads characters from a HTML-file.
Example:
HTMLReader r=new HTMLReader(new File("index.html")); int c; while((c=r.read())!=-1) { if(c==-2) System.out.print(" TAG:",r.getTag()); else System.out.print(c); } --> This is the HTML-file, with resolved ampersand sequences and with -2 returned for tags.If the file is UTF8-encoded, consider wrapping an UTF8Reader:
HTMLReader r=new HTMLReader(new UTF8Reader(new File("index.html")));
Field Summary | |
---|---|
boolean |
skipSTYLE
TRUE to skip STYLE attributes |
Constructor Summary | |
---|---|
HTMLReader(java.io.File f)
Constructs a HTMLReader from a File |
|
HTMLReader(java.io.File f,
java.lang.String message)
Constructs a HTMLReader from a File with a progress bar |
|
HTMLReader(java.io.Reader s)
Constructs a HTMLReader from a Reader |
|
HTMLReader(java.net.URL url)
Constructs a HTMLReader for an URL |
Method Summary | |
---|---|
void |
close()
|
java.lang.String |
getTag()
Returns the last tag (uppercased) |
java.lang.String |
getTagContent()
Returns the content of the last tag |
static void |
main(java.lang.String[] argv)
Test routine |
int |
read()
Reads a character, returns -2 for tags |
int |
read(char[] cbuf,
int off,
int len)
|
java.lang.String |
readTaggedText(java.lang.String t)
Seeks the next tag of name t and returns all text to the terminating tag /t. |
java.lang.String |
readTextLine(int n)
Reads a sequence of characters up to the blank following the nth char, ignores tags |
boolean |
scrollTo(java.lang.String s)
Seeks a specific string and scrolls to it, returns TRUE if found |
boolean |
scrollToTag(java.lang.String s)
Seeks a specific tag and scrolls to it, returns TRUE if found |
java.lang.StringBuilder |
text(java.lang.String forTag)
Returns the entire text |
Methods inherited from class java.io.Reader |
---|
mark, markSupported, read, read, ready, reset, skip |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean skipSTYLE
Constructor Detail |
---|
public HTMLReader(java.io.Reader s)
public HTMLReader(java.net.URL url) throws java.io.IOException
java.io.IOException
public HTMLReader(java.io.File f) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public HTMLReader(java.io.File f, java.lang.String message) throws java.io.FileNotFoundException
java.io.FileNotFoundException
Method Detail |
---|
public java.lang.String readTextLine(int n) throws java.io.IOException
java.io.IOException
public java.lang.String getTagContent()
public java.lang.String getTag()
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public java.lang.String readTaggedText(java.lang.String t) throws java.io.IOException
java.io.IOException
public java.lang.StringBuilder text(java.lang.String forTag) throws java.io.IOException
java.io.IOException
public boolean scrollTo(java.lang.String s) throws java.io.IOException
java.io.IOException
public boolean scrollToTag(java.lang.String s) throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.Reader
java.io.IOException
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |