Hy,
I’m expiriencing logical troubles at reading a file, line for line. I know you can do this with BufferedReader, but sometimes I have “values” which are written in more lines, which would be important.
Sample of the file im reading:
<#FIELD NAME = DESC> Some text that goes
over multiple lines
which is needed</#FIELD>
<#FIELD NAME = TEMP> some values are just a single line</#FIELD>
I need to parse the Field Name, which would be TEMP or DESC like above, and then extract the value between those brackets <#FIELD NAME =DESC>important values </#FIELD>. But I’m not really sure how to “recognize” that an entry has a multiple line value or a single value line and then save it to a variable, when using BufferedReader.
I would really appreciate any hint or example to direct me into the right direction !
Because reading it line for line, did not help me progress… I will not post the whole code as I think there is a more easier way to read it and you will get an idea of what I’ve done so far by this little snippet.
if (line.contains("<#FIELD NAME = AUTOR>"))
{
String autor = line.substring(line.indexOf(">") + 1, line.indexOf("</#"));
metaData.setAutor(autor.trim());
}
else if (line.contains("<#FIELD NAME = DOKUMENTNR>"))
{
String dokumentnr = line.substring(line.indexOf(">") + 1, line.indexOf("</#"));
metaData.setDoukumentnr(dokumentnr.trim());
...
try something like
In the original code, something like