Package org.miaixz.bus.core.lang
Class Console
java.lang.Object
org.miaixz.bus.core.lang.Console
命令行(控制台)工具方法类 此类主要针对
System.out 和 System.err 做封装。- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiderror()同 System.err.println()方法,打印控制台日志static void同 System.err.println()方法,打印控制台日志static void同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈static void同 System.err.println()方法,打印控制台日志static void同 System.err.println()方法,打印控制台日志static Stringinput()读取用户输入的内容(在控制台敲回车前的内容)static Integer返回当前行号 (不支持Lambda、内部类、递归内使用)static voidlog()同 System.out.println()方法,打印控制台日志static void同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈static void同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈static void同 System.out.println()方法,打印控制台日志 当传入template无"{}"时,被认为非模板,直接打印多个参数以空格分隔static void同 System.out.println()方法,打印控制台日志static void同 System.out.print()方法,打印控制台日志static void同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈static void同 System.out.print()方法,打印控制台日志static voidprintProgress(char showChar, int len) 打印进度条static voidprintProgress(char showChar, int totalLen, double rate) 打印进度条static Scannerscanner()创建从控制台读取内容的Scannerstatic voidtable(Console.Table consoleTable) 打印表格到控制台static Stringwhere()返回当前位置+行号 (不支持Lambda、内部类、递归内使用)
-
Constructor Details
-
Console
public Console()
-
-
Method Details
-
log
public static void log()同 System.out.println()方法,打印控制台日志 -
log
同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈- Parameters:
obj- 要打印的对象
-
log
同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈- Parameters:
obj1- 第一个要打印的对象otherObjs- 其它要打印的对象
-
log
同 System.out.println()方法,打印控制台日志 当传入template无"{}"时,被认为非模板,直接打印多个参数以空格分隔- Parameters:
template- 文本模板,被替换的部分用 {} 表示values- 值
-
log
同 System.out.println()方法,打印控制台日志- Parameters:
t- 异常对象template- 文本模板,被替换的部分用 {} 表示values- 值
-
table
打印表格到控制台- Parameters:
consoleTable- 控制台表格
-
print
同 System.out.print()方法,打印控制台日志- Parameters:
obj- 要打印的对象
-
print
同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈- Parameters:
obj1- 第一个要打印的对象otherObjs- 其它要打印的对象
-
print
同 System.out.print()方法,打印控制台日志- Parameters:
template- 文本模板,被替换的部分用 {} 表示values- 值
-
printProgress
public static void printProgress(char showChar, int len) 打印进度条- Parameters:
showChar- 进度条提示字符,例如“#”len- 打印长度
-
printProgress
public static void printProgress(char showChar, int totalLen, double rate) 打印进度条- Parameters:
showChar- 进度条提示字符,例如“#”totalLen- 总长度rate- 总长度所占比取值0~1
-
error
public static void error()同 System.err.println()方法,打印控制台日志 -
error
同 System.err.println()方法,打印控制台日志- Parameters:
obj- 要打印的对象
-
error
同 System.out.println()方法,打印控制台日志 如果传入打印对象为Throwable对象,那么同时打印堆栈- Parameters:
obj1- 第一个要打印的对象otherObjs- 其它要打印的对象
-
error
同 System.err.println()方法,打印控制台日志- Parameters:
template- 文本模板,被替换的部分用 {} 表示values- 值
-
error
同 System.err.println()方法,打印控制台日志- Parameters:
t- 异常对象template- 文本模板,被替换的部分用 {} 表示values- 值
-
scanner
创建从控制台读取内容的Scanner- Returns:
Scanner
-
input
读取用户输入的内容(在控制台敲回车前的内容)- Returns:
- 用户输入的内容
-
where
返回当前位置+行号 (不支持Lambda、内部类、递归内使用)- Returns:
- 返回当前行号
-
lineNumber
返回当前行号 (不支持Lambda、内部类、递归内使用)- Returns:
- 返回当前行号
-