Tai Yo wrote:I have a text file with contents:
OK, so it sounds like you have a text file that is being used as "metadata" to build the components of a GUI.
There's nothing particularly wrong with that, but I hope you realise that there are MUCH better languages to do this than
Java.
Specifically, you will probably be using reflection to create your components, which is an
extension to the language, not part of it; so you will have no
syntactical (or compiler) help when you write a program to parse this sort of file.
However, in terms of
format, it would appear that you are now faced with a new level of "indentation" that you didn't expect.
I don't intend to go into the specifics of
your format, but basically you can deal with that in two ways:
1. Proceduarally - re-write your "input" method to handle extra the level of detail by assuming that any "level 2"
String may also be a
List.
2. Re-write your entire input logic to treat the incoming data as a proper "tree".
I have a preference for the latter, because it's generic, and there are any number of "tree" implementations in Java on the Net (not to mention in the Java Collections Framework itself), and it'll save you from having to re-write
again if you ever run into a 4th or 5th level of indentation.
Once you have a structure, how you compose it into Strings (or arrays of Strings) is up to you and your application.
HIH
Winston