Java Reference
In-Depth Information
return
return false
false
;
}
}
The
ContLineReader
class ends with code for handling the
read()
calls so that the class
will work correctly. The
IndentContLineReader
class extends this to allow merging of lines
Example 10-9. IndentContLineReader.java
public
public class
class
IndentContLineReader
IndentContLineReader
extends
extends
ContLineReader
{
/** Line number of first line in current (possibly continued) line */
public
public
int
int
getLineNumber
() {
return
return
firstLineNumber
;
}
protected
protected
String prevLine
;
/** Read one (possibly continued) line, stripping out the '\'s that
* mark the end of all but the last.
*/
public
public
String
readLine
()
throws
throws
IOException
{
String s
;
// If we saved a previous line, start with it. Else,
// read the first line of possible continuation.
// If non-null, put it into the StringBuffer and its line
// number in firstLineNumber.
iif
(
prevLine
!=
null
null
) {
s
=
prevLine
;
prevLine
=
null
null
;
}
else
else
{
s
=
readPhysicalLine
();
}
// save the line number of the first line.
firstLineNumber
=
super
super
.
getLineNumber
();
// Now we have one line. If we are not in continuation
// mode, or if a previous readPhysicalLine() returned null,
// we are finished, so return it.
iif
(!
doContinue
||
s
==
null
null
)
return
return
s
;