Run gzip and sqlldr on UNIX

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.
jen2483Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Runtime.getRuntime().exec("gunzip data.txt.gz");
0
 
CEHJCommented:
(Since you say you know how to run sqlldr in Java, i assume that's all you need help with...)
0
 
Tommy BraasCommented:
Hi jen2483,

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

\t
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Tommy BraasCommented:
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
 
objectsCommented:
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
 
sciuriwareCommented:
WARNING!

     GZIPInputStream fails on files that expand to > 4Gb

In that case you are forced to use gunzip.
;JOOP!
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.