英語版では、(気分的にであって、文法は目をつぶってください) "An exception of SomeException is thrown at the method 'meth(int, int)' with some instance of class 'A'. " としたいです。
ここで、書式文字列をそれぞれ "クラス%2$sのメソッド%3$sで、ある例外%1$sが発生しました。" "An exception of %1$s is thrown at the method \'%3$s\' with some instance of class \'%2$s\' " とし、あてはめる値を "SomeException", "A", "meth(int,int)" とすれば、うまくいきそうなことが分かりました。
>、固定文字列でないと、出力が失敗してしまいます。 (定数ではなく変数を使用すると失敗するようです。) そんなことはありません。 普通に変数を使用してString#formatメソッドを呼び出 せます。 class A { public static void main(String[] args) { String message = "An exception of %1$s is thrown at the method \'%3$s\' with some instance of class \'%2$s\' ";
System.err.println(String.format(message, "SomeException", "A", "meth(int,int)")); } } で An exception of SomeException is thrown at the method 'meth(int,int)' with some instance of class 'A' と出力されます。 messageがプロパティから取得した値だろうと同じで す。 他のところに問題があるのでは?