This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Zip file through SSH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Zip file through SSH" Watch "Zip file through SSH" New topic

Zip file through SSH

Micky Pat

Joined: May 03, 2006
Posts: 18
Dear All,

I am trying to solve the following problem.
I am developing a Java application on a Windows machine; the data for this application resides in an Unix server (which I can usually browse using a SSH connection in a putty console).
Now, my problem is: I would to access the data in this server, the data are contained in zip files (there is one entry per each each zip, currently).
I found this package, jsch-0.1.33, which allows you to obtain an InputStream for the zip file, you can wrap it in a ZipInputStream, and from this object you can retrieve the entries, but how can I retrieve the InputStream from each entry? Note that, differently from what I am used to do in my local machine, I can't instantiate the remote ZipFile object, I can only get the OutputStream.

Is this possible to do? Am I using a wrong package for my purpose? Do you know any other solution?

Thanks in advance

Micky Pat

Joined: May 03, 2006
Posts: 18

I sorted out the problem myself.
Within the JSch package, once I get the InputStream for the zip file out the Channel object, I can get and read a stream for the ZipEntry in this way: zipIn = new;
DataInputStream dataIn = new DataInputStream(zipIn);

So the trick is using the ZipInputStream to instantiate a DataInputStream.

Other question though

In the same context as before, how can I run a query to a remote database?
I agree. Here's the link:
subject: Zip file through SSH
It's not a secret anymore!