Problems with Umlauts in java

I am trying to read some data through the Console and write it to a file. I am having problems when data from the console has umlaut characters. Is he typing "?" instead of umlaut characters. Below is the code of my code. Can someone please help me

String cmd = "cmd /C si viewproject"+ cmdLine+" --recurse --fields=indent,name --project="+name; Process p = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader(new InputStreamReader( p.getInputStream())); String line = null; File filename = new File(System.getProperty("java.io.tmpdir"), "Project" + ".tmp"); OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(filename), Charset.forName("UTF-8").newEncoder()); while ((line = in.readLine()) != null) { osw.write(line); osw.write("\n"); } osw.close(); 
+4
source share
1 answer

Try running cmd with cmd /U and read the input as UTF-16LE.

See this question. What encoding / codepage is cmd.exe using? for more information.

+2
source

All Articles