• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to execute gunzip -c > outputfile command from java

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to decompress the .gz file and put the decompressed file in another location by keeping original file(.gz) without any modification.

Line 1. Runtime run=Runtime.getRuntime();
Line 2. Process process=run.exec("/bin/gunzip -c /root/yy/fileName.gz >
/root/xx/fileName");
Line 3. process.waitFor();
Line 4. int val=process.exitValue();

The above command works fine in Linux terminal.But when i try to execute from runtime,it does not work. Is there any problem in code?It does not reach the Line 4.If i paste the above command in terminal,it works fine.
Please help me to resolve this issue.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may need to handle the output streams as described here in this article.
 
BWA HA HA HA HA HA HA! Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic