File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes MessageFormat Help ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "MessageFormat Help ?" Watch "MessageFormat Help ?" New topic
Author

MessageFormat Help ?

hasan khan
Ranch Hand

Joined: Aug 04, 2003
Posts: 222

I am reading a String from a file which look like this
12^45^67^45^34^56^43^32^297^O^36^35^35^35^35^1^50^26

the length of the string is not fix.
i want to read the first three number ignoring the rest.

import java.text.*;
public class messageformat
{
public static void main(String[] args) throws ParseException
{
MessageFormat mf = new MessageFormat("{0}^{1}^{2}");
String message = "12^45^67^45^34^56^43^32^297^O^36^35^35^35^35^1^50^26";
Object obj[] = mf.parse(message);

for(int i=0; i<obj.length; i++)
{
System.out.println(obj[i]);
}
}
}
The output is
12
45
67^45^34^56^43^32^297^O^36^35^35^35^35^1^50^26

but i only want 1st three numbers i.e 12, 45, 67
how to i do ?
i am also looking for some good examples of how to use MessageFormat ?
please help ...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: MessageFormat Help ?
 
Similar Threads
Another question on Synchronization and Locks
toString() method invoked
Convert Into Java Code.
Project Euler problems with Scala
string extraction by giving position as first argument in command prompt