Example from input file:
ARTIST="unknown"
TITLE="Rockabye Baby"
LYRICS="Rockabye baby in the treetops
When the wind blows your cradle will rock
When the bow breaks your cradle will fall
Down will come baby cradle and all
"
The Artist, Title & Lyrics fields have to be extracted to their respective Strings with captalization and format unchanged. This code for the Artist field
while (readIn.hasNext()) {
readToken= readIn.next();
if (readToken.contains("ARTIST")) {
artist= readIn.next();
}
if (readToken.contains("TITLE")){
title= readIn.next();
System.out.print(artist+" "+title);
}
ends up printing this out:
"unknown"
TITLE null"unknown"
TITLE null"unknown"
TITLE
From the code, I can't see why the output is printing this way. For every time through the loop, the readToken string gets refreshed, and should then be compared by the contains() method. Obviously I'm missing something here.
So, am I close to the right track or am I in a completely different city?