Package eu.bandm.tools.util.files
Class PrintWriter_limited
java.lang.Object
java.io.Writer
java.io.PrintWriter
eu.bandm.tools.util.files.PrintWriter_limited
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Prints only the n first characters and igores the rest.
Useful in debugging for printing the prefix of a structure dump
which would otherwise be (ergonomically) too large for the context.
(For instance, whole tdom dumps, of which only the head information needs to be read.)
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Signals to a caller that the number of characters to print is reached. -
Field Summary
Modifier and TypeFieldDescriptionprotected int
Internal counter of characters.protected boolean
Flag that limit has been reached.static final String
Public cache for the os-dependent line-separator string, as retrieved bySystem.getProperty("line.separator")
.protected final int
Limit on characters.Fields inherited from class java.io.PrintWriter
out
-
Constructor Summary
ConstructorDescriptionPrintWriter_limited
(PrintWriter out, int maxcount) Constructor setting the target of the prints and the limit in character count. -
Method Summary
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
Methods inherited from class java.io.Writer
nullWriter
-
Field Details
-
LS
Public cache for the os-dependent line-separator string, as retrieved bySystem.getProperty("line.separator")
. -
count
protected int countInternal counter of characters. -
maxcount
protected final int maxcountLimit on characters. -
fin
protected boolean finFlag that limit has been reached.
-
-
Constructor Details
-
PrintWriter_limited
Constructor setting the target of the prints and the limit in character count.
-
-
Method Details
-
reset
public void reset()Reset the counter and start counting anew. -
print
Print a string, but only the firstcount
characters. When this limit is reached, throwPrintWriter_limited.PrintFinished
. Flush the output after each call.- Overrides:
print
in classPrintWriter
- Throws:
PrintWriter_limited.PrintFinished
-
println
Print a string followed by a line feed.- Overrides:
println
in classPrintWriter
-