• IO之Object流举例


    import java.io.*;
    
    public class TestObjectIO {
        public static void main(String args[]) throws Exception {
            T t = new T();
            t.k = 8;
            FileOutputStream fos = new FileOutputStream("d:/share/java/io/testobjectio.dat");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(t);
            oos.flush();
            oos.close();
            
            FileInputStream fis = new FileInputStream("d:/share/java/io/testobjectio.dat");
            ObjectInputStream ois = new ObjectInputStream(fis);
            T tReaded = (T)ois.readObject();
            System.out.println(tReaded.i + " " + tReaded.j + " " + tReaded.d + " " + tReaded.k);
            
        }
    }
    
    class T 
        implements Serializable
    {
        int i = 10;
        int j = 9;
        double d = 2.3;
        transient int k = 15;
    }
  • 相关阅读:
    JSON
    FBV & CBV
    django Tips
    Django2.2
    cookie & session
    ajax请求
    视图函数
    模板语法
    模板继承、组件
    python之路-----多线程与多进程
  • 原文地址:https://www.cnblogs.com/janson071/p/10079475.html
Copyright © 2020-2023  润新知