Solved

Run gzip and sqlldr on UNIX

Posted on 2004-10-19
7
776 Views
Last Modified: 2008-03-10
I need to have a program to run gzip first, it will unzip the data.txt.gz file. Then I will usse this program to run sqlldr. I need to run this program on UNIX. I know how to run sqlldr in java, any suggestion?

Thanks.
0
Comment
Question by:jen2483
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 12350891
Runtime.getRuntime().exec("gunzip data.txt.gz");
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12351092
(Since you say you know how to run sqlldr in Java, i assume that's all you need help with...)
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 12351945
Hi jen2483,

Using a GZIPInputStream would allow you not to rely on gzip being installed on the system.

\t
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Tommy Braas
ID: 12351984
jen2483,

Try this:

            FileInputStream fis = new FileInputStream("data.txt.gz");
            GZIPInputStream gzis = new GZIPInputStream(fis);
            byte []buffer = new byte[1024];
            FileOutputStream fos = new FileOutputStream("data.txt");
            int len = 0;
            while ( (len = gzis.read(buffer, 0, len)) != -1)
            {
                fos.write(buffer, 0, len);
            }
            gzis.close();
            fis.close();
            fos.close();
0
 
LVL 92

Expert Comment

by:objects
ID: 12352929
heres an example of running exec() if you decide to use that route, though using GZIPInputStream would be a cleaner approach.

http://www.objects.com.au/java/examples/util/ConsoleExec.do
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12355373
WARNING!

     GZIPInputStream fails on files that expand to > 4Gb

In that case you are forced to use gunzip.
;JOOP!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12456232
8-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question