I have a plain text file, format as follows:
-@-How to Google
-@-Google is Awesome!!!
I would avoid using scanner delimiters. Just read each line and process it in code. For each line, first throw away (or ignore) any leading white space. Then if the line starts with a delimiter, wrap up any pending link/output (see below for what that means). Then,
-~-, the text from there to the end of the line is the start of a link, so start accumulating link text (in, say a
StringBuilder). Also, if you have a non-empty output list, append the list to the list of lists
-@-, it's the start of an output, so start accumulating output text.
To "wrap up any pending link/output", convert the current contents of the
StringBuilder to a
String and add to the appropriate list. Also append any non-empty output list to
There are a lot of bookkeeping details to attend to here that I haven't addressed, but that's the basic idea.