当我启动我的 maven 构建时,它失败并出现此错误
"Conversion = s, Flags = #"
在下面的测试中。
public class Test {
public static void main(String[] argv) {
String a = String.format("%1$#" + (250 + 1) + "s", "");
System.out.println("a = " + a);
}
}
请指教。
谢谢。
最佳答案
所以这真的完全取决于一个看起来像这样的调用:
String.format("%1$#251s", "");
如果您查看 Formatter
文档,此格式字符串请求字符串转换 (s
),宽度为 251,标志为 #
。
字符串转换文档说明:
If the '#' flag is given and the argument is not a Formattable , then a FormatFlagsConversionMismatchException will be thrown.
现在 java.lang.String
没有实现 Formattable
- 所以异常被抛出,正如记录的那样。
您期望这样做的目的是什么?
关于Maven 构建的 Java 格式字符串错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12805969/