There is such code:
import java.io.BufferedReader; import java.io.InputStreamReader; public class PingIP { public static void runSystemCommand(String command) { try { Process p = Runtime.getRuntime().exec(command); BufferedReader inputStream = new BufferedReader( new InputStreamReader(p.getInputStream())); String s = ""; // reading output stream of the command while ((s = inputStream.readLine()) != null) { System.out.println(s); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { String ip = "google.com"; runSystemCommand("ping " + ip); } } Saved the file in different encodings from vs studio code. Saving in Cyrillic 1251 in the screenshot. How to fix the encoding? Cmd displays ping responses in Russian by default. Maybe you can change the English, but it is in the background, I would like to in Russian.

new InputStreamReader(p.getInputStream(), "UTF-8"));, as Andrey Bystrov suggests - MrFylypenko