Have you ever felt the need for copying an output generated on command line to clipboard, or wanted to paste from clipboard to command line?

The following java utilities (cross-platform) will help you do just that.

Usage:
=> To copy the output of a program to clipboard
echo Hello World | java ClipCopy
dir | java ClipCopy

=> To paste the clipboard contents to a file
java ClipPaste > clip.txt

This can also be used to remove the requirement to create temporary files in a complex batch/shell script.

To type clipboard contents directly from command line just type: java ClipCopy
End with content with end character of your OS, Ctrl-Z for windows & Ctrl-D for Unix.

Download:
ClipCopy.class
ClipPaste.class

For line counters, ClipCopy is 4 lines of code and ClipPaste is 2 lines of code. This doesn't take into account the import, class & main declarations and opening & closing braces.

Let me know if you find this useful.

Note: For non-Java users you might find it easier to download the jar file and run the modified commands as shown below:
Usage:
=> To copy the output of a program to clipboard
echo Hello World | java -cp clip.jar ClipCopy
dir | java -cp clip.jar ClipCopy

=> To paste the clipboard contents to a file
java -cp clip.jar ClipPaste > clip.txt

This takes care of any classpath setting issue. You still need to have jre installed in your system.

Limitation: Not tested with binary content. This is meant for text transfers only.