Getting data from the computer clipboard

Getting data from the system clipboard is implemented nicely in Java through the Toolkit class which has a getSystemClipboard method.
Since there isn’t necessarily text contents in the clipboard the getSystemClipboard returns an instance of the class Transferable.
With that instance we have to test if the content is text before we do any processing with it.
To test the code, just copy some text from the browser or some other document and have the java program print it out.

Search for more Java info on this site here:
Custom Search

Please type any questions here.