use of java.awt.datatransfer.Transferable in project suite by stupidsing.
the class ClipboardUtil method getClipboardText.
public String getClipboardText() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard.getContents(null);
String text;
if (contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor))
try {
text = contents.getTransferData(DataFlavor.stringFlavor).toString();
} catch (UnsupportedFlavorException ex) {
LogUtil.error(ex);
text = "";
} catch (IOException ex) {
LogUtil.error(ex);
text = "";
}
else
text = "";
return text;
}
Aggregations