Reputation: 157
In Java how can I execute the following shell command:
osmosis --read-xml file="planet-latest.osm" --bounding-polygon file="country.poly" --write-xml file="australia.osm"
I tried executing it with this code:
Process proc = Runtime.getRuntime().exec("osmosis --read-xml file="planet-latest.osm" --bounding-polygon file="country.poly" --write-xml file="australia.osm"");
InputStream output = proc.getInputStream();
but it seems that the Unix command is not executed.
Upvotes: 1
Views: 3575
Reputation: 2311
try escaping the double "
Process proc = Runtime.getRuntime().exec("osmosis --read-xml file=\"planet-latest.osm\" --bounding-polygon file=\"country.poly\" --write-xml file=\"australia.osm\"")
Upvotes: 1
Reputation: 3191
Using the Runtime is a deprecated way of executing commands. Take a look at ProcessBuilder
Upvotes: 1