读书人

JAVA读取带汉语参数的properties文件

发布时间: 2012-09-12 09:21:30 作者: rapoo

JAVA读取带中文参数的properties文件

import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.util.Properties;public class Test {private static Properties properties = new Properties();public static void main(String[] args) {try {InputStream is = Test.class.getClassLoader().getResourceAsStream("jdbc.properties");properties.load(is);String size = properties.getProperty("jdbc.password");System.out.println("----" + size);String name =new String(properties.getProperty("jdbc.password").getBytes("ISO8859-1"),"UTF-8");System.out.println("----"+name);} catch (FileNotFoundException e) {} catch (IOException e) {}}}

??? properties文件

jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost/testjdbc.username=rootjdbc.password=哈哈
?

读书人网 >编程

热点推荐