My program reads with Scanner class few words from a file and compare them to users output. My editor is NetBeans and OS Windows 7. I first ran the program in NetBeans and had no problems. When I ran it in the command prompt, scandinavian characters (ä, ö, å, Ä, Ö, Å) didn't display correctly. Well, I tested and gave different parameters for Scanner, like ISO-8859-1 but it didn't help. Finally, I gave UTF-8 for it and characters also display well. But I got a new problem. I use equals method to compare two words. But now it doesn't "work". Though the words should be equals method returns false. If I haven't any character set for Scanner the program works well in NetBeans but not in the command prompt. So what can I do and why doesn't equals method work? Should I create my own comparing method or something?
public void readingWordsFromFile(String textfile){
try{
File f = new File("WordLists\\" + textfile + ".txt" );
Scanner l = new Scanner(f, "UTF-8");
try{
int i = 1;
while( l.hasNext() ){
String temp = l.nextLine();
words.put(i, temp);
i++;
}
}
catch (Exception e){
}
finally{
l.close();
}
}
catch (Exception e){
}
}
Edit: "Solved". The answer doesn't relate to character sets. Files contained BOM because I had accidentally saved them with Notepad. So now I use again Notepad++ and everything is fine. : )