Write a string to the system clipboard in Java
Description
The following code shows how to write a string to the system clipboard.
Example
//w ww . jav a 2 s. c o m
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
public class Main {
public static void main(String[] argv) throws Exception {
StringSelection ss = new StringSelection("str");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
}