• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Copying file from Java to System clipboard help

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting and Setting Text on the System Clipboard
 
S Saunders
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
S Saunders
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic