nikunj2512
nikunj2512

Reputation: 621

unzip a .zip file in hadoop using java

I have a .zip file into the hadoop cluster named 'test.zip'. I am trying to unzip it into the hadoop cluster and store it under the name test.txt but, file is not getting unzipped and my below code is not giving me any error.

Code is able to unzip the file but not able to save the unzipped file into the cluster.

Upvotes: 1

Views: 422

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 192013

The code does unzips the file but doesn't saves it to the hadoop cluster

You're building a local FileOutputStream, and never writing anything back to HDFS

 File newFile = new File(outputFolder + "/" + fileName);
 new File(newFile.getParent()).mkdirs();

These need to replaced with a mkdirs call to the FileSystem fs object.

Or try to use fs.createFile() method, which returns an OutputStream builder that you can write to

Upvotes: 1

Related Questions