标签:style blog color os ar java for sp div
最新想做个访问系统剪贴板的功能,网上的资料大多是单独访问文字和图片的。下面这种可以访问图文混合内容(只适用于word)
1 Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard(); 2 Transferable clipTf = sysClip.getContents(null); 3 DataFlavor[] dataList = clipTf.getTransferDataFlavors(); 4 int wholeLength = 0; 5 for (int i = 0; i < dataList.length; i++) { 6 DataFlavor data = dataList[i]; 7 if (data.getSubType().equals("rtf")) { 8 Reader reader = data.getReaderForText(clipTf); 9 OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("d:\\test.rtf")); 10 char[] c = new char[1024]; 11 int leng = -1; 12 while ((leng = reader.read(c)) != -1) { 13 osw.write(c, wholeLength, leng);
15 } 16 osw.flush(); 17 osw.close(); 18 } 19 }
标签:style blog color os ar java for sp div
原文地址:http://www.cnblogs.com/justeene/p/4024042.html