My problem ist about a little java program written using NetBeans 7.4. There is obviously an encoding issue since I need to handle German input containing special characters (äüöÄÜÖß).
Reading in text from files works like a charm, special characters are saved and displayed as expected:
String fileText = new Scanner(file, "UTF-8" ).useDelimiter("\\A").next();
However I also need to read the user input from console - in this case I only care about the one in NetBeas itself since this code will not be used outside the IDE. Entering special characters here leads to the usual symbols (box, question mark) instead of the umlauts.
Scanner scanner = new Scanner(System.in, "UTF-8");
userQuery = scanner.nextLine();
Input: könig
Output: k�nig
I have been stuck on this for quite a while now, having tried every option Google brought my way, but so far no luck. Most people seem to have fixed this by changing the standard encoding (Project Properties -> Sources -> Encoding), which is already set to UTF-8 though.
There is no issue using those characters in any other way, such as saving them in strings or printing them to the console. So the issue seems to be with the NetBeans console encoding setting.
I tried manually changing that without any luck. I'm not sure this setting even affects the NetBeans console, since trying to access the console object just returns null.
System.setProperty("console.encoding", "UTF-8");
Anybody have an idea where to look next? I have already exhausted all Google searches (not much useful on pages > 5, as always).
Thanks!