Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下代码:
private static final String PATTERN = "file_%d.txt"; int no; // 1-3 String filename = String.format(PATTERN, no ,Locale.US);
后来我得到一个例外说
java.io.FileNotFoundException: file_٣.txt
这表明 %d 被替换为阿拉伯数字。如果我明确指定 Locale.US,那怎么可能?
语言环境需要是第一个参数:
String.format(Locale.US,PATTERN, no);