code: public static void writeToClipboard(String text) {
          Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
          Transferable transferableText = new StringSelection(text);
          systemClipboard.setContents(transferableText, null);
      }
docs: Write a text to system clipboard
  
  @param text text to write