首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2012-09-12 
JAVA读取带中文参数的properties文件import java.io.FileNotFoundExceptionimport java.io.IOExceptioni

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=哈哈
?

热点排行