Hi all,
Does the following code, which gets a class from a remote server, caches the class on the client machine?
URL u = new URL("http://1.2.3.4:80/JavaClasses/MainClass.class");
InputStream input = u.openStream();
DataInputStream data = new DataInputStream(input);
byte classBytes[] = downloadByteCodesFromURL(data);
Class c = defineClass("MainClass", classBytes, 0, classBytes.length);
//////////////////////////
public static byte[] downloadByteCodesFromURL( DataInputStream in) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
while (true) {
try {
outStream.write(in.readByte());
}
catch (IOException e) {
break;
}
}
return outStream.toByteArray();
}
Thank you