/**
* 输出的数据流 相当于一次加密
*/
public static void testData(){
DataOutputStream dos = null;
try {
dos = new DataOutputStream(new FileOutputStream(new File("data.txt")));
dos.writeUTF("我爱你,而你却不知道!");
dos.writeBoolean(true);
dos.writeLong(15371247239L);
} catch (IOException e) {
e.printStackTrace();
}finally {
if(dos != null){
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
* 输出的数据流 相当于一次加密
*/
public static void testData(){
DataOutputStream dos = null;
try {
dos = new DataOutputStream(new FileOutputStream(new File("data.txt")));
dos.writeUTF("我爱你,而你却不知道!");
dos.writeBoolean(true);
dos.writeLong(15371247239L);
} catch (IOException e) {
e.printStackTrace();
}finally {
if(dos != null){
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 输入的数据流 相当于解密
*/
public static void testData1(){
DataInputStream dis = null;
try {
dis = new DataInputStream(new FileInputStream(new File("data.txt")));
String str = dis.readUTF();
System.out.println(str);
boolean b = dis.readBoolean();
System.out.println(b);
long l = dis.readLong();
System.out.println(l);
} catch (IOException e) {
e.printStackTrace();
}finally {
if(dis != null){
try {
dis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}