import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
String data = (String) Toolkit.getDefaultToolkit()
.getSystemClipboard().getData(DataFlavor.stringFlavor);
with the getData()
Method and the stringFlavor
you should get plain text from the clipboard.
If there are weird text in the clipboard, I think, this should be a problem of the program which puts the data in the clipboard.