code: public static String getText(){
          Transferable contents = clipboard().getContents(null);
          try{
              if(contents!=null && contents.isDataFlavorSupported(DataFlavor.stringFlavor))
                  return (String)contents.getTransferData(DataFlavor.stringFlavor);
              else
                  return null;
          }catch(UnsupportedFlavorException ex){
              throw new ImpossibleException(ex);
          }catch(IOException ex){
              throw new RuntimeException(ex);
          }
      }
docs: returns the current text contents of clipboard. If clipboard
  has no text contents or has no content, it returns null