Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading a properties file from a server

Status
Not open for further replies.

Kruzer

Programmer
Jun 16, 2000
117
US
I need to grab a a.properties file from the server, use the parameters throughout for other classes.

I have a constants class created

public static final something = "";
...

I have this code started, but I'm not sure if this is what I need to do to get the properties file off the server.

import java.util.Properties;
import java.io.FileInputStream;

public class MyProperties extends Properties{

public MyProperties() {}

public MyProperties(String absoluteName) throws Exception {
super();
FileInputStream is = new FileInputStream(absoluteName);
load(is);
is.close();
}
}

Dano
dskryzer@hotmail.com
What's your major malfunction
 
You're on the right track. You don't really need to subclass properties though. You could just use a Properties object and create a method to load the Properties from your file in the main class. Other than that, what you are doing will work fine.

 
Could you, in code syntax, show me what you mean?

public class MyProperties {

Properties obj = Properties();


Dano
dskryzer@hotmail.com
What's your major malfunction
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top