File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Copying file from Java to System clipboard help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Copying file from Java to System clipboard help" Watch "Copying file from Java to System clipboard help" New topic
Author

Copying file from Java to System clipboard help

S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
I am trying to write some code that will allow the user to select a file in a java application and then be copied to the system clipboard for them to paste into a folder in the Windows Explorer.
Currently when I try this, the path of where the file exists is copied. I go to the Explorer and try to paste, but the Paste option is not enabled. I am using the following code to copy the file to the clipboard:

Is it possible to transfer a file from Java and have it recognized by the system? If so, will you point me to documentation/example of how it can be done.
Thanks.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Getting and Setting Text on the System Clipboard


"JavaRanch, where the deer and the Certified play" - David O'Meara
S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
Originally posted by Cindy Glass:
Getting and Setting Text on the System Clipboard

I appreciate the response. I can currently copy/paste a string, but would like to know if it is possible to paste a "file handle" from java, such that Windows would recognize it as a file and not as text. Currently, I have been unsuccessful at finding a solution.
Steve
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Although I don't know the answer to your question, I wanted to point out that such an action is probably very dependant on the specific platform where it runs (Windows in this case). This seems to go against the platform-independant philosophy that drives Java development. I am sure that you could do this in C with the Windows API, but it seems to be somewhat contrary to the typical mindset of a Java programmer.
With that said, perhaps you can still find a way to do it. I wish you luck in your continued search.
Layne


Java API Documentation
The Java Tutorial
S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
Layne,
You bring up a good point. I guess I hoped for a simple solution in Java. Thanks for the reminder, and I will begin looking at doing it with code outside of java.
Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Copying file from Java to System clipboard help