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

doubt in files and Directories

 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have doubt in getting list of files in a directory as in K&B book page 442 using list() function they are getting directory name also but I am not getting in my code shown as below. Is my correct or do I need to add anything to get dir name also?
Can any one help me in this.
correct me if I am wrong

Thanks in advance
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Divya,

you request a list of all entries in directory mydir which only contains two files, file.txt and file2.txt. Which directory do you expect?
 
Murali Kakarla
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the example on page 442 they are getting names of sub-directories and files under the directory 'searchThis'.

Since in your case you have only two files under 'mydir' it does not print any directory names.

Murali...
SCJP 5 Aspirant
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me how to print directory name?
 
Murali Kakarla
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Divya,

I hope following example will clarify your doubt.



Murali...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic