I'm trying to run a bash cmd that grabs infomation from the google api using my api key. I run the code in the terminal and I get the output that I want (which is the address alone). But when I try use the call within java it doesnt work. I believe it ends up being a null call.
The cmd is as follows: "wget -O- -q "https://maps.google.com/maps/api/geocode/json?address=4-chōme-2-8 Shibakōen, Minato City, Tokyo 105-0011, Japan&key=[MY_API_KEY]"|grep '"formatted_address"'|cut -d\: -f2
This is my current java code
public static void main(String[] args) throws Exception {
Process runtime = Runtime.getRuntime().exec("wget -O- -q \"https://maps.google.com/maps/api/geocode/json?address=4-chōme-2-8 Shibakōen, Minato City, Tokyo 105-0011, Japan&key=[MY_API_KEY]\"|grep '\"formatted_address\"'|cut -d\\: -f2");
Show_Output(runtime);
}
public static void Show_Output(Process process) throws IOException {
BufferedReader output_reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String output = "";
while ((output = output_reader.readLine()) != null) {
System.out.println(output);
}
System.out.println(output);
}
Desired output is: "4-chōme-2-8 Shibakōen, Minato City, Tokyo 105-0011, Japan",