title: Failing to write german 'umlauts' (äöü) from console to text file with java
body: <p>currently I'm desperately trying to write german umlauts, read from the console, into a utf8 encoded text file on windows 7.</p>
  
  <p>Here is the code to setup the scanner: </p>
  
  <pre><code>Scanner scanner = new Scanner(System.in, "UTF8");
  </code></pre>
  
  <p>Here is the code to read the string:</p>
  
  <pre><code>String s = scanner.nextLine();
  </code></pre>
  
  <p>Here is the code to write into a file:        </p>
  
  <pre><code>    OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(this.targetFile), "UTF8");
  
  osw.write(s);
  </code></pre>
  
  <p>Unfortunately, instead of example "überraschung" the so written file is encoded in utf8 but will not display the umlaut. What to do?</p>