Are there any java string function that I can use together with some form of config driven configuration that anyone can suggest?
Well there is the obvious one: the 'substr' method of the String class.
Your 'config' would be the list of start/end or start/length values for each of the components.
The usual parsing issue is knowing how to determine when one element ends and the next one starts. For this fragment of yours:
How do you know if the first component, 'ch_code', is '1', '2', or '122'?
I'd rather suggest regular expressions:
The biggest Problem I see is: how do you know what string comes next?
Hi, I am inclined to think that the configuration you have mentioned initially can work well. Also you might want to put a flag after Presenter in config marking when the repetition starts. As suggested by few others as well go with substr to keep things simple.
Here I would extract header data in a sequence of substr's until I see the flag and then run a loop till the end of the input string (I am assuming that the length of field in every record is same).