Java tutorial
import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; public class Main { public static void main(String[] argv) throws Exception { Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) { String text = (String) t.getTransferData(DataFlavor.stringFlavor); System.out.println(text); } } }