public class AdvancedReader extends Object
BufferedReader
).
Mais il faut aussi pouvoir dire qu'en fin de compte on ne souhaite pas lire
les caracteres que l'on vient de lire (unread(int)
a peu pres egal a
PushbackReader
)
Le pointer nextChar pointe toujours sur le prochain caractere qui sera lu
Lorsque l'on appelle la method mark()
on vide aussi le buffer pour
liberer de la place, car on a plus le moyen de retourner avant le mark que
l'on vient de positionner.
On contraire du mark de BufferedReader
ou LineNumberReader
il
n'y a pas a specifier le nombre de caractere a garder au maximum, seul la
memoire nous limite. Du coup si l'on utilise cette classe sans mark, au final
on aura dans le buffer tout le contenu du reader, il faut donc utiliser mark
avec cette classe
buffer
######################### 0 ˆ ˆ | | | + nextChar + markCharCreated: 27 oct. 06 00:24:57
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.collections.primitives.CharList |
buffer |
protected int |
charNumber |
protected int |
charNumberMark |
protected Reader |
in |
protected int |
lineNumber |
protected int |
lineNumberMark |
protected int |
markChar |
protected int |
nextChar |
protected boolean |
nlTwoCtrlChars |
protected boolean |
noNlAtEOF |
protected static int |
READ_AHEAD
nombre de caractere lu au minimum sur le vrai reader
|
protected int |
readInMark |
protected static String |
TAB
le nombre d'espace pour remplacer les tabulations
|
Constructor and Description |
---|
AdvancedReader(Reader in) |
Modifier and Type | Method and Description |
---|---|
void |
add(char character)
Add a character at the current position
|
boolean |
eof() |
int |
getCharNumber() |
int |
getLineNumber() |
void |
mark() |
int |
read()
read one char in buffer
|
String |
readLine()
read one line
|
String[] |
readLines(int count)
lit un certain nombre de lignes
|
int |
readSinceMark() |
String[] |
readUntil(String pattern)
lit les lignes jusqu'a la ligne qui correspond pas au pattern, cette
ligne n'est pas mise dans le resultat retourne
|
String[] |
readUntilBlank()
lit les lignes jusqu'a la premiere ligne blanche (non retournée)
|
String[] |
readWhile(String pattern)
lit les lignes tant que les lignes correspondent au pattern
|
void |
reset() |
int |
skip(int number) |
void |
skipBlankLines()
passe les lignes blanches
|
int |
unread(int number)
go left in reading char buffer
|
int |
unread(String[] lines,
boolean addNewLine)
Unread the line length
|
int |
unread(String line,
boolean addNewLine)
Unread the line length
|
protected static final String TAB
protected static final int READ_AHEAD
protected Reader in
protected org.apache.commons.collections.primitives.CharList buffer
protected int charNumber
protected int charNumberMark
protected int lineNumber
protected int lineNumberMark
protected int nextChar
protected int markChar
protected int readInMark
protected boolean nlTwoCtrlChars
protected boolean noNlAtEOF
public AdvancedReader(Reader in)
in
- the io readerpublic void mark() throws IOException
IOException
public void reset() throws IOException
IOException
public int readSinceMark()
public int getCharNumber()
public int getLineNumber()
public boolean eof() throws IOException
IOException
public int skip(int number) throws IOException
IOException
public void add(char character)
character
- that you want to addpublic int unread(int number)
number
- public int unread(String line, boolean addNewLine)
line
- line used to know the length to unreadaddNewLine
- if true then add +1 to unread lenght for not present '\n'public int unread(String[] lines, boolean addNewLine)
lines
- lines used to know the length to unreadaddNewLine
- if true then add +1 for each line to unread lenght for not
present '\n'public int read() throws IOException
IOException
- pour tout pb de lecturepublic String readLine() throws IOException
IOException
- pour tout pb de lecturepublic void skipBlankLines() throws IOException
IOException
public String[] readLines(int count) throws IOException
count
- si negatif lit toutes les lignesIOException
- pour tout pb de lecturepublic String[] readUntilBlank() throws IOException
IOException
- pour tout pb de lecturepublic String[] readUntil(String pattern) throws IOException
pattern
- ?IOException
- pour tout pb de lecturepublic String[] readWhile(String pattern) throws IOException
pattern
- ?IOException
- pour tout pb de lectureCopyright © 2004–2014 CodeLutin. All rights reserved.