java中的关键字(transient)
transient这个关键字并不常见,主要应用在java的序列化方面。这里我再多说,转一篇老外的文章,很生动,欣赏吧
Be Careful With Transient Data
Java's serialization provides an elegant, and easy to use mechanism for making an object's state persistent. While controlling object serialization, we might have a particular object data member that we do not want the serialization mechanism to save.
To turn off serialization on a certain field of an object, we tag that field of the class of our object with the Java's "transient" keyword. This, to low-level parts of the Java virtual machine, is an indication that the transient variable is not part of the persistent state of an object.
First, let's have some backgrounder code with Java's serialization.
Suppose we define a class as:
public class LoggingInfo implements java.io.Serializable
{
private Date loggingDate = new Date();
private String uid;
private transient String pwd;
LoggingInfo(String user, String password)
{
uid = user;
pwd = password;
}
public String toString()
{
String password=null;
if(pwd == null)
{
password = "NOT SET";
}
else
{
password = pwd;
}
return "logon info: \n " + "user: " + uid +
"\n
相关文档:
keytool生成证书
验证是否已创建过同名的证书
keytool -list -v -alias tomcat -keystore "%JAVA_HOME%/JRE/LIB/SECURITY/CACERTS" -storepass changeit
删除已创建的证书
keytool -delete -alias tomcat -keystore "%JAVA_HOME%/JRE/LIB/SECURITY/CACERTS" -storepass changeit
创建证书
1.服务 ......
1.拆分字符串
遇到特殊字符,比如:对‘$’符号,就应该使用‘\\$’,后总结可以加个方括号如 "[.]"。
2.遍历HASHMAP
Iterator itr = map.keySet().itrator();
while(itr.hasNext())
{
Object temp1 = itr.next();
Object temp2 = tab.get(temp1);
}
......
jdk提供了Zip相关的类方便的实现压缩和解压缩。使用方法很简单。下边分别是压缩和解压缩的简单事例
1,压缩的
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import ......
将字串 String 转换成数字类型
String 转 int
1.) int i = Integer.parseInt([String]); 或 i = Integer.parseInt([String],[int radix]);
2.) int i = Integer.valueOf(my_str).intValue();
String 转 Float
Float f = Integer.valueOf(my_str).floatValue();
String 转 float
float f=new Float(my+str).floa ......
java的范型机制看起来有点像C++的模版,但相比较C++的模版类,java中的范型没有关键字template,并且有着不同的实现机制(本质区别)。
范型类
先看一个范型类的例子:
public class Demo1<T> {
private T value;
public Demo1(T value) {
&n ......