Get html from the specified clipboard. This is a little tricky. Let’s take a look at the code.
/** * 从指定的剪切板中获取html * @param clipboard * @return * @throws Exception */ public static String getClipboardHtml(Clipboard clipboard) throws Exception { if(clipboard == null){ clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();//获取系统剪贴板 } // 获取剪切板中的内容 Transferable clipT = clipboard.getContents(null); if (clipT != null) { DataFlavor dataFlavor = new DataFlavor("text/html;class=java.lang.String"); return String.valueOf(clipT.getTransferData(dataFlavor)); } return null; }
The above is the detailed content of How to get html based on specified clipboard?. For more information, please follow other related articles on the PHP Chinese website!