1

I am building a database and I want to be able to store a user input filepath and have it available as a variable even after the application is closed and restarted to prevent retyping the path with each launch.

Bman76
  • 47
  • 6

1 Answers1

2

Use a file where you store the information in the form :

key=value

For example :

filepath=C://myFolder

And use Properties to retrieve the information from the file.

https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • Now the only thing that needs to be done is locating that file... If you store it in a jar, you'll have problems writing to it; if you store it outside, you'll probably face difficulties locating it... – fabian Jan 06 '17 at 22:24
  • Storing it outside should be the privileged solution in rich-client applications. Generally, the file is defined in a path relative to the directory where the application is copied/installed but it may also be the user directory. – davidxxx Jan 06 '17 at 22:28
  • Thanks for the assistance I actually forgot about the properties class to store info. – Bman76 Jan 07 '17 at 03:21
  • 1
    You are welcome. Properties should be unforgettable :) – davidxxx Jan 07 '17 at 08:13