I have a URL which will return a single jar file or a zip file containing multiple jar files. I don't know the return type.
I have another function which accepts a list of ClassLoaders, I want to read the jar(s) into memory and pass them to the function. (I cannot store anything on the drive.)
Here is what I have so far:
//Read url content
URL url = new URL(myUrl);
URLConnection uc = url.openConnection();
String userpass = UserName + ":" + Password;
String basicAuth = "Basic " + new String(new Base64().encode(userpass.getBytes()));
uc.setRequestProperty("Authorization", basicAuth);
InputStream in = uc.getInputStream();
ZipInputStream zis = new ZipInputStream(in);
ZipEntry entry;
final int BUFFER = 2048;
//Here I need to check to see if it's a jar or a zip ??
while ((entry= zis.getNextEntry()) != null) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] data = new byte[2048];
while (zis.available() > 0) {
out.write(zis.read());
}
//How to proceed from here ??
}
//Here I want to return list<ClassLoader>
Aucun commentaire:
Enregistrer un commentaire