java.util.scanner - Java Scanner cannot read words with accent mark -


i have problem code. if add words accent mark file, scanner won´t read it.thank help.

for example if file "names.txt" contains: john lil none

number of words in file 3

but if contains: jóhn lil none

number of words in file 0

code is:

    file file=new file("names.txt");     scanner skener=new scanner(file);       int count=0;      while(skener.hasnext()){          aarraylistofnames.add(skener.next());         count++;     }      skener.close();     system.out.println("count "+count);     return count; 

thank all, problem fixed! :d

construct scanner defining charset should use:

scanner skener=new scanner(file,"utf-8"); 

i believe ascii default charset scanner needs changed. file might not encoded in utf-8.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -