I am trying to create a boolean method that will read all the words from a source file. I have a hit a roadblock. All suggestions and tips are greatly appreciated! Here is my unfinished code:
public class WordCloud {
ArrayList<WordPair> list;
public WordCloud() {
list = new ArrayList<WordPair>();
}
public boolean getWordsFromFile (String filename) throws IOException {
File sourceFile = new File (filename);
Scanner input = new Scanner (sourceFile);
String allText = "";
while (input.hasNext())
{
if (input.next){
String allText = input.next();
list.add(allText);
}
return true;
}
}
Aucun commentaire:
Enregistrer un commentaire