
com.antiaction.common.cli.ProgressableOutput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-cli Show documentation
Show all versions of common-cli Show documentation
Multipurpose library for handling commnad line interface arguments.
The newest version!
package com.antiaction.common.cli;
import java.io.OutputStream;
import java.io.PrintStream;
public class ProgressableOutput extends PrintStream {
public ProgressableOutput(OutputStream out) {
super(out);
}
@Override
public void close() {
super.close();
}
@Override
public void flush() {
super.flush();
}
protected static char[] spacesArr = new char[256];
static {
for (int i=0; i s.length()) {
String spaces = new String(spacesArr, 0, lastProgressWidth);
super.print(spaces);
super.print("\r");
}
}
super.print(s);
lastProgressWidth = s.length();
}
@Override
public synchronized void print(String s) {
if (lastProgressWidth > 0) {
String spaces = new String(spacesArr, 0, lastProgressWidth);
super.print("\r");
super.print(spaces);
super.print("\r");
lastProgressWidth = 0;
}
super.print(s);
bNL = false;
}
@Override
public synchronized void println(String x) {
if (lastProgressWidth > 0) {
String spaces = new String(spacesArr, 0, lastProgressWidth);
super.print("\r");
super.print(spaces);
super.print("\r");
lastProgressWidth = 0;
}
super.println(x);
bNL = true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy