• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File access standards

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something I've been wondering about for a while. If I'm trying to access a properties file I'll include it's path in my code. But ideally, it's nice to have a properties file that stores the path location of other files. Where will it stop? What can I do so I don't have to hardcode any path into my software? Is there a standard location where the jvm looks for files if there's no specific path provided?
Thanks.
Paul
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. You can write your app to whatever default you want. What I would typically do is offer a command-line option so the user can specify a props file when starting the app:
java MyClass -p C:\Java\misc\foo\bar\myclass.properties
If the user doesn't specify a props file, you can specify a default behavior, such as looking for a file called myclass.properties in the current directory, or in the user's home directory (System.getProperty("user.home")). If no such file is found, maybe bring up a dialog asking the user "hey, where's the damn props file?" or some such (with a "create new configuration" option that leads to a new configuration wizard). Lots of choices, depending how user-friendly you want the whole thing to be, and how much time you want to put into it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic