import java.lang.*; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.text.MessageFormat; import java.text.ParseException; /** * Sample for MessageFormat. */ class MessageFormatSample { /** * Do it. */ public void doIt() { BufferedReader ins = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = ins.readLine()) != null) { try { MessageFormat mf = new MessageFormat("{0} {1} {2}"); Object[] objs = mf.parse(line); String s = (String)objs[0]; int i = Integer.parseInt(String.valueOf(s.charAt(s.length()-1))); System.out.println(" result is "+objs[0]+","+objs[1]+","+objs[2]); System.out.println(" i is " + i); } catch (ParseException pe) { System.out.println(" parse error"); } } ins.close(); } public static final void main(String args[]) throws IOException { MessageFormatSample sample = new MessageFormatSample(); sample.doIt(); } }