com.fastchar.utils.FastPrintUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastchar Show documentation
Show all versions of fastchar Show documentation
FastChar is Web+ORM Framework in Java.
package com.fastchar.utils;
public class FastPrintUtils {
public synchronized static void printProgress(int curr, int total, int length) {
printProgress('[', ']', '*', ' ',
curr, total, length);
}
public synchronized static void printProgress(char startBound, char endBound,
char progress, char secondProgress,
int curr, int total, int length) {
System.out.print('\r');
double perValue = FastNumberUtils.formatToDouble(curr) / FastNumberUtils.formatToDouble(total);
int perString = FastNumberUtils.formatToInt(perValue * 100);
String preTip = perString + "%";
int currProgressLength = (int) (perValue * length);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(startBound);
for (int i = 0; i < length; i++) {
if (i <= currProgressLength) {
stringBuilder.append(progress);
} else {
stringBuilder.append(secondProgress);
}
}
stringBuilder.append(preTip);
stringBuilder.append(endBound);
System.out.print(stringBuilder);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy