vendredi 20 février 2015

Java IO fails to read text file



when I try to read thesaurus.txt, it reads it as "ÿþ ", although the first entry is "<pat>a cappella". What could be causing this?



File file = new File("thesaurus.txt");
Scanner scan;
try {
scan = new Scanner(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
scan = null;
}
String entry;
ArrayList<String> thes = new ArrayList<String>();
while(scan.hasNext())
{
entry = scan.nextLine();
if(entry != "")
{
thes.add(entry);
}
}
return thes;



Aucun commentaire:

Enregistrer un commentaire