• Post Reply Bookmark Topic Watch Topic
  • New Topic

default directory using FileChooser

 
glen li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have two questions:

1. How can I specify a default directory when using FileChooser?
2. How can I put a text file into a .jar executable and read that file when I run the program?

Thanks!

glen
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhh, the API is a wonderful thing.


public JFileChooser(File currentDirectory)

Constructs a JFileChooser using the given File as the path. Passing in a null file causes the file chooser to point to the user's default directory. This default depends on the operating system. It is typically the "My Documents" folder on Windows, and the user's home directory on Unix.

Parameters: currentDirectory - a File object specifying the path to a file or directory


As far as your second question, you actually have 2 questions in 1. Both of which would be better in a different forum. Take a look at the Jar Tutorial for information on Jaring files up. As far as reading the resource, use something like:



Then just use normal IO for loading the url into some sort of stream to read it. If you don't know how to do this, you might ask in the I/O and Streams forum seeing as how it's not really a Swing issue.
 
glen li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gregg, I can figure it out based on the info. you gave me, big help.

glen
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!