Copying to the clipboard in Java

Viewed 91478

I want to set the user's clipboard to a string in a Java console application. Any ideas?

5 Answers

For anyone still stumbling upon this post searching for the JavaFX way to accomplish this, here you go:

ClipboardContent content = new ClipboardContent();
content.putString("Some text");
content.putHtml("<b>Bold</b> text");
Clipboard.getSystemClipboard().setContent(content);

For further information, read the documentation.

Related