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();
source share