This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes how to execute gunzip -c > outputfile command from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to execute gunzip -c > outputfile command from java" Watch "how to execute gunzip -c > outputfile command from java" New topic
Author

how to execute gunzip -c > outputfile command from java

elay Raja
Greenhorn

Joined: Jun 10, 2008
Posts: 27
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
You may need to handle the output streams as described here in this article.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to execute gunzip -c > outputfile command from java