๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17117

file properties

#17117
From: walter b.
Date: Thu, 10 Dec 1998 00:00
64 lines
2164 bytes
I'm writing a prog and my source path and my class path is
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: <366fa36f.129539@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,a1f1f00ec4f3d305,start
X-Google-Attributes: gidf74b3,public
From: wbelcore@ats.it (walter b.)
Subject: file properties
Date: 1998/12/10
Message-ID: <366fa36f.129539@forums.borland.com>
X-Deja-AN: 421800811
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language