I am working on a zipper J2EE application. This application requires the following:
The application has to zip a folder in remote machine where app server is running so that other applications can directly download this zipped folder instead of downloading each file one by one.
I am able to do this in my local machine using absolute path don’t know how to go ahead with remote machine.
Code i’m using for zipping in local machine:
File file = new File(myFolderPath);
int index = myFolderPath.lastIndexOf("/");
String folderName =myFolderPath.substring(index);
String folderPath = myFolderPath.substring(0, index);
File outFolder = new File(folderPath + folderName + ".zip");
if (!outFolder.exists()) {
zip(file, outFolder);
}
Here myFolderPath is a string. But how should i go ahead if it is a URL?
Thanks in advance.
URLs don’t allow directory listings, so this is not possible. You will need absolute paths on the server, too, or convert the URL to an absoltue path on the server, maybe by replacing a http://server/ with the root folder of the webapp.