How to execute Shell Script from Java

process = Runtime.getRuntime().exec("ping google.com");
process.waitFor();

BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader readerError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

String retornoSucess = "";
String retornoError = "";

while ((retornoSucess = reader.readLine()) != null) {
    sb.append(retornoSucess + "\n");
}

while ((retornoError = readerError.readLine()) != null) {
    sb.append(retornoError + "\n");
}

System.out.println(retornoSucess);
System.out.println(retornoError);