You are trying perfectly right things. All you need it to put them together.
Another idea: for performance sake, its much better to use the class
. It is mutable, but strings are immutable
, so concatenating strings repeatedly will kill good performance. After parsing strings into some fragments, you
then one by one to the instance of
. To go back from
to string, simply use