I had a simple task to complete, unzip a file using java, because I wanted to it multiple times by reading a config file, the code was supposed to be very easy.
Something like this:
But it turns out that calling unzip hangs forever, so I found an stackoverflow post (https://stackoverflow.com/questions/34088099/executing-unzip-command-programmatically) that had the solution, and I ended doing it like this:
As you can see this is a little bit different, it calls unzipFile.sh that basically does execute unzip command with the parameters passed by.
I was not alone with this problem, there are plenty of posts and questions about this on stackoverflow, but for some reason these did not work for me:
https://mkyong.com/java/how-to-execute-shell-command-from-java/
Comments