8166050: partialArray is not created in javax.swing.text.html.parser.NPrintWriter.println(...) method

Reviewed-by: prr
This commit is contained in:
Prasanta Sadhukhan 2022-02-07 04:48:02 +00:00
parent 2f48a3f032
commit 5dfff7406e

View File

@ -162,43 +162,3 @@ class TagStack implements DTDConstants {
next + " <" + tag.getElement().getName() + ">";
}
}
class NPrintWriter extends PrintWriter {
private int numLines = 5;
private int numPrinted = 0;
public NPrintWriter (int numberOfLines) {
super(System.out);
numLines = numberOfLines;
}
public void println(char[] array) {
if (numPrinted >= numLines) {
return;
}
char[] partialArray = null;
for (int i = 0; i < array.length; i++) {
if (array[i] == '\n') {
numPrinted++;
}
if (numPrinted == numLines) {
System.arraycopy(array, 0, partialArray, 0, i);
}
}
if (partialArray != null) {
super.print(partialArray);
}
if (numPrinted == numLines) {
return;
}
super.println(array);
numPrinted++;
}
}