Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

copying files to pendrives via java

 
sahil sethi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
Tony Docherty
Bartender
Posts: 2941
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic