Run gzip and sqlldr on UNIX

Posted on 2004-10-19
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?

Question by:jen2483
LVL 86

Accepted Solution

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

Expert Comment

ID: 12351092
(Since you say you know how to run sqlldr in Java, i assume that's all you need help with...)
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.

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 14

Expert Comment

by:Tommy Braas
ID: 12351984

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 =, 0, len)) != -1)
                fos.write(buffer, 0, len);
LVL 92

Expert Comment

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

Expert Comment

ID: 12355373

     GZIPInputStream fails on files that expand to > 4Gb

In that case you are forced to use gunzip.
LVL 86

Expert Comment

ID: 12456232

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
custom annotations 9 42
how to see all occupied ports on windows 10 laptop 15 76
iterator/ListIterator approach 17 39
how to debug htl and js pages 8 39
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

837 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