The latest want to make a access to the system Clipboard function, the information on the Internet is mostly separate access to text and pictures. The following can be used to access text mixed content (only for word)
1Clipboard Sysclip =Toolkit.getdefaulttoolkit (). Getsystemclipboard ();2Transferable CLIPTF = sysclip.getcontents (NULL); 3dataflavor[] DataList =cliptf.gettransferdataflavors ();4 intWholelength = 0;5 for(inti = 0; i < datalist.length; i++) {6DataFlavor data =Datalist[i];7 if(Data.getsubtype (). Equals ("RTF")) {8Reader reader =Data.getreaderfortext (CLIPTF);9OutputStreamWriter OSW =NewOutputStreamWriter (NewFileOutputStream ("D:\\test.rtf"));Ten Char[] C =New Char[1024]; One intLeng =-1; A while((Leng = Reader.read (c))! =-1) { - Osw.write (c, Wholelength, Leng);
the } - Osw.flush (); - osw.close (); - } +}
Java Access clipboard (mixed graphics)