File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Zip file through SSH

 
Micky Pat
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Micky Pat
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool,

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:

java.util.zip.ZipInputStream zipIn = new java.util.zip.ZipInputStream(is);
zipIn.getNextEntry();
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic