Answer the question
In order to leave comments, you need to log in
How to print output from Process in normal encoding?
I run a bat file and take an outputstream from it with
Process pro = Runtime.getRuntime().exec(file.toString());
OutputStream stdin = pro.getOutputStream();
InputStream stdout = pro.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stdout));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
Process pro = Runtime.getRuntime().exec(file.toString());
OutputStream stdin = pro.getOutputStream();
InputStream stdout = pro.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stdout, "CP866"));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
new Thread(() -> {
while (true){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
try {
writer.write(s+"\n");
writer.flush();
}catch (IOException e){
e.printStackTrace();
}
}
}).start();
byte line;
while ((line = (byte) reader.read()) != -1) System.out.print(new String(new byte[]{line}));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question