Article View: borland.public.jbuilder.java.language
Article #17106propertie repost
From: walter b.
Date: Tue, 22 Dec 1998 00:00
Date: Tue, 22 Dec 1998 00:00
63 lines
2161 bytes
2161 bytes
I'm writing a program My source path and my class path are
c:\jbuilder2\myprog\.
I want save customer's preferences into properties file.
Now I don't want insert source path into file propetrie name (because
when I deploy my program I install into c:\myprog or other path), but
without path I get file not found exception.
How can I solve this problem ?
This is my code:
public class Options extends JFrame {
Properties prop;
TextFieldControl textFieldDirArch = new TextFieldControl();
File f = new File("settaggi.properties");
/* jave not funds settaggi.properties, But if I write new
File("c:/jbuilder2/myprog/settaggi.properties") it works. But like
this I have absolute path
*/
// etc....
public Options() {
try {
jbInit();
if (!f.isFile())
{
Msg.warning("Path file "+f.getPath() + " not found");
// Msg my class messagebox
return;
}
try {
InputStream in = new FileInputStream(f);
prop = new Properties();
prop.load(in);
textFieldDirArch.setText(prop.put("dir_archivi","d:/archivi").toString());
// with this textfield customer can to set archives's path
in.close();
}
catch(Exception eReadProp)
{Msg.warning(eReadProp.getMessage());}
}
//....
void buttonSave_actionPerformed(ActionEvent e) {
// scrive nel file
try {
registra(); // my method for to set properties's keys
OutputStream out = new FileOutputStream(f);
prop.save(out,"bo");
out.flush();
out.close();
f = null;
prop = null;
new Setta();
this.dispose();
}
catch(Exception eSaveProp) {Msg.warning("errore nella scrittura
del file di propriet๏ฟฝ "+eSaveProp.getMessage());}
}
Technical Details
Message-ID:
<367f9882.745284@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f74b3,8dec30e424270b5d,start X-Google-Attributes: gidf74b3,public From: wbelcore@ats.it (walter b.) Subject: propertie repost Date: 1998/12/22 Message-ID: <367f9882.745284@forums.borland.com> X-Deja-AN: 424825408 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language