3
I’m trying to use the method .format
string. But if I put %1, %2, etc. in the string, the java.util exception.Unknownformatconversionexception is released, pointing to a confusing Java code:
private void checkText(String s) {
int idx;
// If there are any '%' in the given string, we got a bad format
// specifier.
if ((idx = s.indexOf('%')) != -1) {
char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1));
throw new UnknownFormatConversionException(String.valueOf(c));
}
}
I conclude that the character %
is prohibited. If so, what I should use as arguments to be replaced?
I use Scala 2.8.
Daniel, you explicitly mentioned version 2.8 of Scala. But the best way to "Format" Strings in Scala came with interpolation in version 2.10. For anyone interested: link to the documentation.
– Anthony Accioly