首页 > 代码库 > Properties 使用,注意编码
Properties 使用,注意编码
private static void setConfig(){ try { // String path = System.getProperty("user.dir") + "\\dbpool.properties"; String path = "./lib/setting.txt"; // FileInputStream is = new FileInputStream(path); Properties props = new Properties(); // props.load(is); props.setProperty("dslname",textField.getText().trim()); props.setProperty("dslacc",textField_1.getText().trim()); props.setProperty("dslpsw",textField_2.getText().trim()); //props.store (is); PrintStream fW = new PrintStream(new File(path)); props.list(fW ); // timeout = Integer.parseInt(props.getProperty("timeout")); // waitforresult=Integer.parseInt(props.getProperty("waitforresult")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); System.err.println("????????????"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); System.err.println("??????????????"); } } private static void readConfig(){ try { // String path = System.getProperty("user.dir") + "\\dbpool.properties"; String path = "./lib/setting.txt"; FileInputStream is = new FileInputStream(new File(path)); // FileInputStream. Properties props = new Properties(); InputStreamReader reader = new InputStreamReader(is,"UTF-8"); props.load(reader); //props.load(is); dslname=props.getProperty("dslname"); dslacc=props.getProperty("dslacc"); dslpsw=props.getProperty("dslpsw"); textField.setText(new String(dslname.getBytes("utf-8"),"utf-8")); textField_1.setText(dslacc); textField_2.setText(dslpsw); // timeout = Integer.parseInt(props.getProperty("timeout")); // waitforresult=Integer.parseInt(props.getProperty("waitforresult")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); System.err.println("????????????"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); System.err.println("??????????????"); } }
Properties 使用,注意编码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。