Class LimitedLineLengthReader
java.lang.Object
java.io.Reader
edu.uky.cs.nil.tt.LimitedLineLengthReader
- All Implemented Interfaces:
Closeable, AutoCloseable, Readable
A
Reader which throws an exception if it reads more than a certain
number of characters before encountering an end of line. This reader is used
to secure other IO utilities like BufferedReader which read
whole lines of input at a time. Malicious users could cause problems such as
OutOfMemoryError by sending long streams of information without a new
line character.- Author:
- Stephen G. Ware
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionLimitedLineLengthReader(Reader reader, int limit) Wraps a new limited line length reader around a given reader and with the given limit on line length. -
Method Summary
Methods inherited from class Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
Constructor Details
-
LimitedLineLengthReader
Wraps a new limited line length reader around a given reader and with the given limit on line length.- Parameters:
reader- the reader from which characters will be readlimit- the number of characters which may be read before an end of line character
-
-
Method Details
-
read
- Specified by:
readin classReader- Throws:
IOException- if the reader reads more than its limit of characters without encountering a new line character
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-