Hi,
Is there any way to save the output file to a user specified directory?
I would like for the user to be able to select a directory and save the
output file there. At the very least, is there any way to specify where
the file is saved by writing it into the code. I know that in C++ you
can specify where the file is created by doing something like this
"C:\\mydir\myprogram.cpp" when you name the file. Does Java allow
something like this?
Andrew Thompson - 27 Jun 2005 15:01 GMT
> Is there any way to save the output file to a user specified directory?
> I would like for the user to be able to select a directory and save the
> output file there.
See FileDialog[1] or JFileChooser[2].
[1] <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/FileDialog.html>
[2] <http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JFileChooser.html>
>..At the very least, is there any way to specify where
> the file is saved by writing it into the code.
Their is no place like System.getProperty("user.home") [3]
[3]
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperty(java.l
ang.String)>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Ingo R. Homann - 27 Jun 2005 15:04 GMT
Hi aeh,
> Hi,
>
[quoted text clipped - 5 lines]
> "C:\\mydir\myprogram.cpp" when you name the file. Does Java allow
> something like this?
In javax.swing, there is a class called JFileChooser (with the
possibility to select a directory instead of a file), and the other
Windowing-Frameworks provide a similar functionality, I guess.
For saving the File, java.io will help.
Ciao,
Ingo
Leon - 27 Jun 2005 15:15 GMT
> Hi,
>
> Is there any way to save the output file to a user specified directory?
> I would like for the user to be able to select a directory and save the
> output file there.
Look at documentation about
javax.swing.JFileChooser;
javax.swing.filechooser.FileFilter;
> At the very least, is there any way to specify where
> the file is saved by writing it into the code. I know that in C++ you
> can specify where the file is created by doing something like this
> "C:\\mydir\myprogram.cpp" when you name the file. Does Java allow
> something like this?
Yes. By using "test.txt" you use the current directory. "C:\\mydir\\test.txt"
specifies the absolute filename.
Greetings, Leon.