java_my_life 发表于 2013-2-3 12:20:15

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=哈哈
页: [1]
查看完整版本: JAVA读取带中文参数的properties文件