读书人

Java 访问各种资料

发布时间: 2012-12-28 10:29:04 作者: rapoo

Java 访问各种文件

?

1、读取.properties 文件

?

?? ? ? ?Properties config = new Properties();

?

?? ? ? ?InputStream input = null;

?

?? ? ? input = new FileInputStream(path); ? ? ? ? ? ?

?

?? ? ? config.load(input); ? ? ? ? ??

?

?

?

?

?

2、读取Spring配置文件?

?

ApplicationContext ac = new FileSystemXmlApplicationContext(springPath);

?

?

?

3、dom4j读取xml文件

?

?SAXReader saxReader = new SAXReader();?

?

??Document document = saxReader.read(inputXml);

?

?

4、dom4j解析xml字符串

??Document doc = DocumentHelper.parseText(String text)

读书人网 >编程

热点推荐