TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG-DEVEL:306] Linux/Java Question
Quoting Perry Hoekstra (dutchman@uswest.net):
> Greet the sun all,
>
> I have a Linux/Java question. It involves the exec() method.
>
> I instantiated a Runtime object using java.lang.Runtime.getRuntime(). I
> am using the exec method to execute a statement at the command line.
>
> //Gets a runtime environment for executing GUNZIP and TAR.
> Runtime rt = java.lang.Runtime.getRuntime();
>
> //Executes GUNZIP and TAR.
> rt.exec("gunzip -c " + tarFilePath + "/" + tarFiles[i] + " | tar xvf
> -");
>
> The statement decompresses a TAR file using GUNZIP and then extracts the
> member files from the TAR archive. When I type in the statement at the
> command line, it works to unzip and extract my files. However, when I
> run the application, the statement doesn't unzip or extract the files,
> and it doesn't throw an error either. How can I unzip and extract the
> files from a Java application?
>
> Example Statement: gunzip -c
> /home/phoekstra/content/tta/images/001_img.tar.gz | tar xvf -
>
> Thank you,
>
Under linux just
rt.exec("tar -xvzf "+tarFilePath+"/"+tarFiles[i]);
--
Bob Tanner <tanner@real-time.com> | Phone : (612)943-8700
http://www.mn-linux.org | Fax : (612)943-8500
Key fingerprint = 6C E9 51 4F D5 3E 4C 66 62 A9 10 E5 35 85 39 D9