I have a javafx window, and when I drag .class files into it I would like to "transform" them into Class<?>
I tried with Class.forname the problem is that you have to know the package, which is not my case. And I tried to read the .class file with a buffered reader to retrieve the package inside but of course it is not possible to read a .class file.
So I need to find a way to transform any .class file regardless of its location on the computer into Class<?> in my code.
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
for (File file : db.getFiles()) {
String fileName = file.getName();
// Vérifiez si le fichier a l'extension .class
if (fileName.endsWith(".class")) {
//TODO
//GlobalView.getInstance().addClassNode(new ClassNode(new Class( the Class<?> object )));
}
}
}
event.setDropCompleted(success);
event.consume();
}
Aucun commentaire:
Enregistrer un commentaire