• 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
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Sybex 829, Files.list()

 
Greenhorn
Posts: 7
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On page 807: "... the JVM will not follow symbolic links when using the list() method"

This seems not to be correct, the following code does list a directory by a symbolic link.
It prints something like this:
C:\Users\Admin\AppData\Local\Temp\junit3162142126987772402\linkToSubdir, symbolicLink: true
C:\Users\Admin\AppData\Local\Temp\junit3162142126987772402\subdir\subdirfile

 
Saloon Keeper
Posts: 15252
349
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I've verified your findings by running your code. Additionally, I called Files.list() on tempDir, and the returned stream also contains the symbolic link.
 
Author
Posts: 249
10
Scala IntelliJ IDE Netbeans IDE Python Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed, the API documentation does not describe ignoring links, other than this:

Some file systems maintain special links to the directory itself and the directory's parent directory. Entries representing these links are not included.

Given that it bothers to mention these special links, I think it's a strong hint that other links are part of the generated Stream.

By contrast, the documentation for many other methods, for example walk, discuss options (e.g. FileVisitOption.FOLLOW_LINKS) that control this behavior. Since there's no option for controlling this behavior in list(), it would be unfriendly, to say the least, if such things were forcibly ignored.
 
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Noted. Thanks for pointing this out.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic