import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import javax.swing.JFrame;
public class MainClass extends JFrame {
public static void main(String args[]) {
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
System.out.println("Object Name: " + clip.getName());
Transferable contents = clip.getContents(new MainClass().getClass());
if (contents == null)
System.out.println("\n\nThe clipboard is empty.");
else {
DataFlavor flavors[] = contents.getTransferDataFlavors();
for (int i = 0; i < flavors.length; ++i) {
System.out.println("\n\n Name: " + flavors[i].getHumanPresentableName());
System.out.println("\n MIME Type: " + flavors[i].getMimeType());
Class cl = flavors[i].getRepresentationClass();
if (cl == null)
System.out.println("null");
else
System.out.println(cl.getName());
}
}
}
}
|