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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -