Java序列化与反序列化
java 中的序列化与反序列化代码:
//进行序列化
public byte[] getByteArray(String[] str)
{
byte[] bt = (byte[])null;
try {
if (str != null) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(str);
bt = bos.toByteArray();
}
} catch (Exception ex) {
bt = (byte[])null;
ex.printStackTrace();
}
return bt;
}
//进行反序列化
public String[] getArrayList(byte[] bt)
{
String[] Array;
ObjectInputStream objIps;
try
{
objIps = new ObjectInputStream(
new ByteArrayInputStream(bt));
Array = (String[])objIps.readObject();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
return Array;
}
相关文档:
一、向上转型。
通俗地讲即是将子类对象转为父类对象。此处父类对象可以是接口。
1,向上转型中的方法调用。
看下面代码:
package com.wensefu.others;
public class Animal {
public void eat(){
System.out.println("animal eatting...");
}
}
class Bird extends Animal{
public void ......
变量:存储数据的基本单元;一个数据存储空间的表示.
基本数据类型(8种):
byte(1)-->short(2)-->int(4)-->long(8) float(4)-->double(8) boolean(1) char(2)
引用数据类型:
String、数组、类、接口、对象 ......
系统自动抛出的异常
所有系统定义的编译和运行异常都可以由系统自动抛出,称为标准异常,并且 Java 强烈地要求应用程序进行完整的异常处理,给用户友好的提示,或者修正后使程序继续执行。
语句抛出的异常
用户程序自定义的异常和应用程序特定的异常,必须借助于 throws 和 throw 语句来定义抛出异常。
throw是语句抛出 ......
1.
BufferedReader in = new BufferedReader(new FileReader("远程文件"));
in.readLine() ;
l 使用 Java 操作文本文件的方法详解
http://java.ccidnet.com/art/3737/20041108/523627_1.html
l FileReader 是什么类?和 FileInputStream 有什么不同???
ht ......
数字证书:
(一)证书管理
1.keyTool证书管理
(1) 本地数字证书生成命令
keytool -genkeypair -alias www.zlex.org -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36000 -keystore zlex.keystore -dname "CN=www.zle ......