我有一个很奇怪的问题。写完之后:
for (File f : currentFile.listFiles()) {
if (f.isDirectory()){
System.out.println(f.getName()+"\t"+"Dir\t"+Command.getpremission(f)+"\t"+f.getTotalSpace());
}
else{
System.out.println(f.getName()+"\t"+"File\t"+Command.getpremission(f)+"\t"+f.getTotalSpace());
}
我看到此打印:
see.txt File rw 267642728448
see1.txt File rw 267642728456
see2.txt File rw 267642728448
为什么选项卡有问题?
最佳答案
在this question上构建,我使用以下代码来缩进消息:
String prefix1 = "short text:";
String prefix2 = "looooooooooooooong text:";
String msg = "indented";
/*
* The second string begins after 40 characters. The dash means that the
* first string is left-justified.
*/
String format = "%-40s%s%n";
System.out.printf(format, prefix1, msg);
System.out.printf(format, prefix2, msg);
这是输出:
短文字:缩进
looooooooooooooooong文字:缩进
这在
man 3 printf
的“标志字符”部分中进行了记录。