Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Input output question  RSS feed

 
Matthew Fyffe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey, I'm working on a database for a school project and I want to read and write to a file to load/save my information. Now I don't want the file to be one thats address is provided by the user but instead, one that is in a desired location of mine... sort of. Maybe it would be easier to explain another way. I want to save all information to a file called "RunnerStored.txt" that would be located in the folder with the program. The code I used for this feature is



and is written in a JFrame. Now the code works fine and gives me the address of the desired file. However, when the file does not exist, it simply returns null. So to make my question shorter, how can I get the address of the folder that my program is in? Thanks a lot.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The key here is File file = new File(".") which creates a File object that in the current directory.

I'm going to move this to the IO and Streams forum since it has more to do with the IO API.
[ May 14, 2004: Message edited by: Gregg Bolinger ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!