• 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 files to pendrives via java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone

M a new user here and in java too, i working on application that need to copy some files from my one of folder to pen drive (removable disk) attached ,so how can i do that,actually i donot have any idea how it gonna implement so please help me out in this.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sahil, welcome to the Ranch!

If I'm not mistaken, once you plug them into your computer's USB port and get them connected, they are just part of the file system. So you can just write to them like any other drive. If you're using Windows, for example, then your pen drive might be mapped to the E: drive, so you just write to files on the E: drive.

Did that answer your question, or is there more to it than that?
 
sahil sethi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But How to Detect that drive??? and please tell me procedure/code to copy files please(as m a new user)
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what you mean when you say "How to detect that drive?" It isn't your program's job to detect the drive. The operating system will do that and assign a drive letter (if it's Windows) or some other identification (if it's some other O/S). Perhaps you meant to ask how to find out which drive letter Windows assigned, or something like that?

As for how to copy a file, here's some example code which I found in about half a minute using the Google keywords java copy files example: Copy a file.
 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sahil sethi wrote:But How to Detect that drive??? and please tell me procedure/code to copy files please(as m a new user)


Some time ago I wrote some code to detect the insert and removal of removable drives, you can find it here: http://www.keang.co.uk/drive.html
NOte: This uses a basic polling approach and I haven't looked at later versions of Java to see if there is now a better way to go about this.
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic