swing - Drag and drop Outlook emails and other files to Java application -
i have created java application user can drag , drop file save specified folder. using filedrop
, unfortunately doesn't work emails dragged , dropped directly outlook. works when email dropped desktop first (a .eml file created) , dropped application, want bypass step.
can see code below:
new filedrop(panel, new filedrop.listener() { public void filesdropped(java.io.file[] files) { (int i=0; i<files.length; i++) { file newfile = files[i]; byte[] mybytearray = null; try { //get data of file byte array mybytearray = org.apache.commons.io.fileutils.readfiletobytearray(newfile); } catch (ioexception e1) { e1.printstacktrace(); } string newfilename = newfile.getname(); try { //create file fileoutputstream file = new fileoutputstream("projects/"+ newfilename); file.write(mybytearray); file.close(); } catch (ioexception e) { e.printstacktrace(); } } } });
i love hear possible solutions problem.
way, part of error message getting, pointing out problem occurs in public void filesdropped(java.io.file[] files) {
line, since email dropped application not recognized file yet (i guess).
... 2015-06-04 12:10:50.860 java[718:71442] couldn't copy of hfs promise pasteboard 2015-06-04 12:10:50.860 java[718:71442] looked hfspromises on pasteboard, found none. exception in thread "awt-eventqueue-0" java.lang.illegalargumentexception: uri not hierarchical @ java.io.file.<init>(file.java:363) @ net.iharder.dnd.filedrop.createfilearray(filedrop.java:453) ...
thanks in advance.
Comments
Post a Comment