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

Chapter 9 Q1 - relativize  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a problem with explanation. If problems in this snippet was corrected it would be E.

So:


It prints:


/user/.././root/../kodiacbear.txt
/kodiacbear.txt
../lion



And i have a problem with understanding what exactly relativize method does. Why last line prints

../lion

when file kodiacbear.txt is in system root? What am i missing?
 
Marshal
Posts: 60116
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you know what an absolute path and a relative path mean. Have you read the documentation for Path#relativize(Path)? It isn't crystal clear, but it means how you would get from the end of this path to the target of the path passed as an argument. If you start from the location of the kodiacbear.txt file, and lion is in the same directory, ./lion will find the lion file.
 
Seba Doe
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would understand if the answer was ./lion (like you wrote) or /lion (like i thought)

But i am asking - why it's ../lion (double dots)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!