• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Input output question

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic