哦, 不好意思, 是store方法
解决方案 »
- js能不能判断当前浏览器是否是360浏览器?
- 网页解析问题....只能解析本地网页
- 一个连接池,和大家分享下
- 关于struts:在tiles中使用servlet
- 为什么图片显示不了呢
- 点击页面1.jsp的按钮跳出页面2.jsp,得到2.jsp的一个数值关闭窗口后传回数值到1.jsp的一文本框中?
- 请教,那位知道小数点的转义字符是什么?
- 无法识别类中的方法
- 各位高手,帮帮小弟的忙,一个关于javabean连接到数据库的菜鸟问题,在线等!!!
- JSP页面第一行语法报错
- 老问题:enctype='multipart/form-data'不能取得文本框内容的问题
- 为什么我用getParameter取到的是null
public void store(OutputStream out,
String comments)
throws IOException
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method. The stream is written using the ISO 8859-1 character encoding.
Properties from the defaults table of this Properties table (if any) are not written out by this method. If the comments argument is not null, then an ASCII # character, the comments string, and a line separator are first written to the output stream. Thus, the comments can serve as an identifying comment. Next, a comment line is always written, consisting of an ASCII # character, the current date and time (as if produced by the toString method of Date for the current time), and a line separator as generated by the Writer. Then every entry in this Properties table is written out, one per line. For each entry the key string is written, then an ASCII =, then the associated element string. Each character of the key and element strings is examined to see whether it should be rendered as an escape sequence. The ASCII characters \, tab, form feed, newline, and carriage return are written as \\, \t, \f \n, and \r, respectively. Characters less than \u0020 and characters greater than \u007E are written as \uxxxx for the appropriate hexadecimal value xxxx. For the key, all space characters are written with a preceding \ character. For the element, leading space characters, but not embedded or trailing space characters, are written with a preceding \ character. The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded. After the entries have been written, the output stream is flushed. The output stream remains open after this method returns.
Parameters:
out - an output stream.
comments - a description of the property list.
Throws:
IOException - if writing this property list to the specified output stream throws an IOException.
ClassCastException - if this Properties object contains any keys or values that are not Strings.
NullPointerException - if out is null.
Since:
1.2
public Object setProperty(String key,
String value)
Calls the Hashtable method put. Provided for parallelism with the getProperty method. Enforces use of strings for property keys and values. The value returned is the result of the Hashtable call to put. Parameters:
key - the key to be placed into this property list.
value - the value corresponding to key.
Returns:
the previous value of the specified key in this property list, or null if it did not have one.
Since:
1.2
See Also:
getProperty(java.lang.String)
try{
Properties props = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream("resource.properties");
props.load(is);
FileOutputStream out = new FileOutputStream("resource.properties");
props.setProperty("User",user);
props.setProperty("Password",Password);
props.store(out, this.getClass().getName());
return true;
}
catch(Exception e) {
e.printStackTrace();
return false;
} }
try{
Properties props = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream ("resource.properties");
props.load(is);
FileOutputStream out = new FileOutputStream("resource.properties");
props.remove("User");
props.remove("Password");
Object userObj = props.put("User",user);
props.store(out,(String)userObj);
Object passObj = props.put("Password",Password);
props.store(out,(String)passObj);
return true;
}
catch(Exception e) {
e.printStackTrace();
return false;
}
}
File file = new File(...);
FileInputStream fis = new FileInputStream(file);
prop = prop.Load(fid);
String username = prop.getProperty("user");
String passwd = prop.getProperty("passwd");
应该是对的。
public boolean uptLoginInfo(String user, String Password,String login) throws Exception {
try{
Properties props = new Properties();
String url = this.getClass().getClassLoader().getResource("resource.properties").toString();
url = url.substring(6,url.length());
props.load(new FileInputStream(url));
props.setProperty("midaUser",user);
props.setProperty("midaPassword",Password);
props.setProperty("midaLogin",login);
props.store(new FileOutputStream(url), "User Login Information"); return true;
}
catch(Exception e) {
e.printStackTrace();
return false;
}
}