• Post Reply Bookmark Topic Watch Topic
  • New Topic

Processing Fixed Format String / Data

 
JV VJ
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am quite new to Java and i would like to find out what is the best approach for processing fixed format strings or stream of data. Suppose i want to send data from my application to an external system in a fixed-format string (no delimeters) and at the same time receive a fixed-format data as well. the data to and from the my application needs to be validated and formatted (e.g. amounts needs to have commas, etc). To be more specific, i want to "send" the following data which is a fundtransfer request (via sockets or whatever transport): abc000100021500USD
the definition is as follows: chars[0-3] = name of customer, next 4 charactes= src account number, next 4 chars=target acct no, next 4 chars = amount, last 3 chars = currency

in return, i expect a cnfirmation or failure response from the target system. i can receive any of the following : 00Success or
01Failed0929 InsufficientFund

What's the best way (in terms of speed and efficiency) of manipulating/parsing data in fixed format in Java?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll wind up with String.substring or working from a byte array.

If you have "meta-data" that describes the record you could automate this a bit.

I wouldn't worry too much about comparing the performance of the various methods unless you had millions of records. Use the technique that seems easiest for readers to understand until you prove it's too slow, and I bet you never will.

Any of that sound useful?
[ May 24, 2005: Message edited by: Stan James ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!