把字符串放到系统剪切板中

Java代码的实现如下: [codesyntax lang="java" lines="normal"]
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;

public class Test {

    public static void main(String[] args)throws Exception
    {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        
        clipboard.setContents(new StringSelection("suren"), null);
    }
}
[/codesyntax]

你可能感兴趣的:(java,剪切板)