Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java IO question  RSS feed

 
Phuc Bui
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I have a simple example about Java IO.
I want to list the name of file and sub-directory of a given directory.
It's easy when I work with a directory from hard disk,
but I can not deal with external storage devices (such as CD and USB)
Please tell me how to solve this problem ???

Thanks so much,
Phuc Bui
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So long as the storage device is correctly mounted and accessible, Java should be able to list what is in there. e.g File myUSBStick = new File("/media/USBStick");

I've just double checked (I wrote a quick application that spiders a directory structure) and it all works fine, even accessing an NTFS formatted USB stick from an Ubuntu box.

What actual problem/exception are you getting?
 
Phuc Bui
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sorry !!! That's silly
I have a mistake, that I can read it but can not write because I do not have right to do this.
I try it again with admin account and it's okay
Thanks for your help
Phuc Bui
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!