This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

difference between /dev/urandom & file:/dev/./urandom  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have doubt in the signature of the two paths which is used as java secure file :

file:/dev/urandom
$
file:/dev/./urandom

can anybody please let me know what is the difference between them..

Thanks
Premchand
 
Saloon Keeper
Posts: 9223
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a Unix champion, but I believe the first one is a path to the file, while the second one executes it (and gives you a secure random number).

Nope, there is no difference. The extra "./" just means "current directory", like it does in Windows.
 
Marshal
Posts: 60110
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like something platform‑specific which you would never see on a Windows® box.

Try putting those two into a Path object (or a java.io.File object) and call getXXX methods on them. Try for the path and the canonical path. I think you will find that the second turns into the first when you use the canonical path. What you have in the first is
  • 1: You are looking for a file on your own machine rather than elsewhere via http, ftp, etc.
  • 2: The / takes you to the very root of the file system.
  • 3: dev/ is one of the directories in the file system.
  • 4: It contains a file called urandom.
  • The difference in the second is that after dev, you are calling ./ Now . means current directory (I think it is the same on Windows®) so ./ means look in the same directory that you were in already. So you can remove the ./ and not change the meaning of the path. Or you can add ./ as often as you like (in the middle of the path String) without changing where you end up.
     
    Campbell Ritchie
    Marshal
    Posts: 60110
    188
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    They are both the same: look. Same output for both

    campbell@campbellsComputer:someDirectory$ file:/dev/urandom
    bash: file:/dev/urandom: No such file or directory
    campbell@campbellsComputer:someDirectory$ file:/dev/./urandom
    bash: file:/dev/./urandom: No such file or directory

     
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!