I have a Java Client/Server application that needs to dynamically load a class from a Class file (or JAR file) attached in a RichText field on a NotesDocument.
Is it possible to user reflection in this case, and if so, how could I get the file to be loaded?
EmbeddedObject file = item.getEmbeddedObject( filename + ".class" );
int length = file.getFileSize();
byte[] bytes = new byte[length];
InputStream is = file.getInputStream();
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "+file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;