windows - Java - Paste a file from clipboard after it has been downloaded -


i have trouble windows explorer.

my application starts download of file , puts system clipboard meanwhile. if user pastes file @ place of windows explorer, file isn't having real size, size depending on progress of download.

does have idea of how advise explorer wait until download has finished , copy file target directory afterwards?

i tried "tunnel" file on loopback interface using local smb server didnt unfortunately...

thanks in advance

downloading file , calling paste clipboard method:

new thread(new runnable() {              @override             public void run() {                  final string = gettext();                  int selectedrows[] = customjtablemodel.table.getselectedrows();                  list<file> filelist = new arraylist<file>();                  for( int i=0; selectedrows.length>i; i++ ) {                      // build relative file/folder path                      string filename = (string)table.getvalueat(table.getselectedrow(), 0);                      final string value = buildpath(where, filename);                      new thread(new runnable() {                          @override                         public void run() {                              staticnetworkdaemon.getfile(value, where);                          }                      }).start();                      filelist.add(new file("\\\\127.0.0.1\\r$\\downloaded" + value.replace("/", "\\")));                  }                  setclipboardfile(filelist);              }          }).start(); 

copying file clipboard:

public static void setclipboardfile(final list<file> files) {      transferable trans = new transferable() {          list<file> filelist = new arraylist<file>();          public dataflavor[] gettransferdataflavors() {              for( file f: files ) {                  filelist.add(f);              }              return new dataflavor[] { dataflavor.javafilelistflavor };          }          public boolean isdataflavorsupported(dataflavor flavor) {              return dataflavor.javafilelistflavor.equals(flavor);          }             public object gettransferdata(dataflavor flavor) throws unsupportedflavorexception, ioexception {              if (isdataflavorsupported(flavor))                  return filelist;              throw new unsupportedflavorexception(flavor);          }      };      toolkit.getdefaulttoolkit().getsystemclipboard().setcontents(trans, null);  } 

what you're doing wrong. don't put in clipboard unless it's ready pasted -- you're breaking contract should following when using clipboard.


Popular posts from this blog