Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

File System Help

 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could someone point me to or give me a good explanation/example of dealing with the location of files within the filesystem. I need to be able to do this on different OS's, but without having to explicitly do the same action 2 different ways and use an if statement to choose every time. I have looked at the java docs on File but it didn't get me very far. I also looked at the Java Tutorial, but it didn't help much either
I need to be able to:

  • findout what the working directory is
  • change the working directory to the location of my program if need be. Once there, I could probably solve the next issue.
  • store a set of resource directories between program sessions. I suppose this could be done with a text file, but I have to know the path to that file so I can open it.
  • avoid hardcoding paths into my code.

  • These are the things I am having a hard time figuring out. Any help with some or all of them would be appreciated.
    Thanks,
    Chris
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic