2024.4.26

package com.IO.kkk;
import java.io.Serializable;
import java.util.Objects;

public class Person implements Serializable {

        private static final long serialVersionUID = 20050210l;
        private float id;
        private String name;
        private int age;

        public float getId() {
            return id;
        }

        public void setId(float id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public Person() {
        }

        public Person(float id, String name, int age) {
            this.id = id;
            this.name = name;
            this.age = age;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Person person = (Person) o;
            return id == person.id && Objects.equals(name, person.name);
        }

        @Override
        public int hashCode() {
            return Objects.hash(id,name);
        }

        @Override
        public String toString() {
            return "xinobi{" + "id=" + id + "name=" + name + "age=" + age;
        }
    }
package com.IO.kkk;
import java.io.*;
public class Ios {
        public static void main(String[] args) {
            Person obito = new Person(010886f,"宇智波带土",29);
            FileOutputStream fis = null;
            ObjectOutputStream ois = null;
            try {
                fis = new FileOutputStream("D://obito");
                ois = new ObjectOutputStream(fis);
                ois.writeObject(obito);
                ois.flush();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                if (ois != null){
                    try {
                        ois.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                if (fis != null){
                    try {
                        fis.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-27 16:10:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-27 16:10:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-27 16:10:03       82 阅读
  4. Python语言-面向对象

    2024-04-27 16:10:03       91 阅读

热门阅读

  1. RabbitMq总结

    2024-04-27 16:10:03       28 阅读
  2. Eureka详解

    2024-04-27 16:10:03       30 阅读
  3. -CMPEN431-SP24-Project-1

    2024-04-27 16:10:03       31 阅读
  4. 4D Solver

    2024-04-27 16:10:03       24 阅读
  5. 大话人工智能之(一)深度学习概念

    2024-04-27 16:10:03       30 阅读
  6. 【pytorch】TensorBoard的使用

    2024-04-27 16:10:03       29 阅读