package test;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.logging.LogFactory;
public class JunitTest {
org.apache.commons.logging.Log log = LogFactory.getLog(JunitTest.class);
public void testLoadFile(){
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("C:\\config.properties");
java.util.Properties properties = new java.util.Properties();
properties.load(fileInputStream);
Object value = properties.get("a");
System.out.println(value.toString());
} catch (FileNotFoundException e) {
try {
fileInputStream.close();
} catch (IOException e1) {
log.error("JunitTest IOException "+e1);
}
} catch (IOException e) {
try {
fileInputStream.close();
} catch (IOException e1) {
log.error("JunitTest IOException "+e1);
}
}
}
}
加载properties文件
最新推荐文章于 2023-04-23 22:29:20 发布