import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
public class Test extends Thread{
public void run()
{
while(true){
try {
this.sleep(1000);
readProperties();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private static void readProperties()
{
Properties p = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(Thread
.currentThread().getContextClassLoader().getResource(
"test.properties").getPath()));
p.load(in);
in.close();
String name = p.getProperty("name");
String id = p.getProperty("id");
System.out.println("id=" + id + "\t name=" + name);
} catch (Exception e1) {
e1.printStackTrace();
}
}
public static void main(String[]args)
{
new Test().start();
}
}
Properties
name=zxc
id=3zxc