Я запускаю bat файл и беру из него outputstream с помощью
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));
Какую кодировку вписать вторым аргументом в InoutStreamReader и какие JVM аргументы нужно писать что-бы получить в консоли русские символы?
Код:
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}));