• java对象序列化并存储到文件中


    ● 如何将一个Java对象序列化到文件里

      使用输入输出流,,一个是ObjectOutputStream 对象,ObjectOutputStream 负责向指定的流中写入序列化的对象。当从文件中读取序列化数据时,主要需要两个对象,一个是FileInputStream ,一个是ObjectInputStream 对象,ObjectInputStream 负责从指定流中读取序列化数据并还原成序列化前得对象。另外,序列化的读取数据与写入的顺序相同,比如我们序列化时先写入数据A ,再写入B ,最后写入C ;那么我们再读取数据的时候,读取到的第一个数据为A ,读取到的第二个数据为B ,最后读取到的数据为C ,即:先写入先读取的原则。

    package com.genersoft.enetbank.settlement.pubbean;
    
    import org.loushang.next.dao.Column;
    import org.loushang.next.dao.Table;
    import org.loushang.next.dao.Transient;
    import org.loushang.next.data.Rule;
    import org.loushang.next.data.StatefulDatabean;
    
    import java.io.FileOutputStream;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.util.Date;
    import java.util.List;
    import java.util.Map;
    
    /**
     * <p>Create Date: 2018-2-27</p>
     * <p>Copyright  : Genersoft Java Group(c)</p>
     * ************************************************************/
    @Table(tableName = "EB_BATCH_PAY", keyFields = "APPLY_ID")
    public class BatchPay extends StatefulDatabean implements Serializable {
    
        //审批状态
        public static final String ADV_DRAW_STATUS_SAVE = "01"; // 申请
        public static final String ADV_DRAW_STATUS_SUBMIT = "02"; // 审批中
        public static final String ADV_DRAW_STATUS_CHECK_RETURN = "04"; // 审批退回
        public static final String ADV_DRAW_STATUS_ABANDONED = "09"; // 作废
    
        public static final String ADV_DRAW_STATUS_REFUSED = "07"; // 财司已拒绝
        public static final String ADV_DRAW_STATUS_CHECKED = "05"; //  网银到柜面后落地未受理:财司受理中
        public static final String ADV_DRAW_STATUS_INPROCESSING = "11"; //财司已受理(柜面审批及发送银行过程都为此状态)
    
        public static final String BILL_STATUS_GMPAYDONE = "08"; // 已支付
        public static final String BILL_STATUS_GMPAYBACK = "12"; // 支付失败退回
    
        /*
         申请内码[YYYYMMDD+12位流水号]
        */
        @Rule(value = "require")
        @Column(name = "APPLY_ID")
        private String applyId;
    
        /*
         付款批号[预留
    ]
        */
        @Column(name = "BATCH_CODE")
        private String batchCode;
    
        /*
         申请编号[]
        */
        @Column(name = "BZNS_CODE")
        private String bznsCode;
    
        /*
         客户编号[]
        */
        @Column(name = "CUST_CODE")
        private String custCode;
    
        /*
         业务类型[对私批量业务类型
    ]
        */
        @Column(name = "BZNS_TYPE")
        private String bznsType;
    
        /*
         申请来源[申请来源:1-Excel导入、2-外部申请
    ]
        */
        @Column(name = "APP_SOURCE")
        private String appSource;
    
        /*
         急缓标志[【客户选择,用以匹配发送方式,0-普通;1-加急】
    ]
        */
        @Column(name = "FAST_FLAG")
        private String fastFlag;
    
        /*
         所属机构[目前默认为客户账户的机构
    ]
        */
        @Column(name = "ORG_ID")
        private String orgId;
    
        /*
            所属机构名称[目前默认为客户账户的机构
       ]
           */
        @Transient
        private String custName;
    
        /*
            组织名称
       ]
           */
        @Transient
        private String orgName;
    
        /*
         客户账户编号[]
        */
        @Column(name = "CUST_ACC_CODE")
        private String custAccCode;
    
        /*
         客户账户名称[冗余
    ]
        */
        @Column(name = "CUST_ACC_NAME")
        private String custAccName;
    
        /*
         客户银行账号[]
        */
        @Column(name = "CUST_BANK_ACC")
        private String custBankAcc;
    
        /*
         币种[]
        */
        @Column(name = "CURCD")
        private String curcd;
    
        /*
         应付金额[]
        */
        @Column(name = "PAY_AMT")
        private BigDecimal payAmt;
    
        /*
         实付金额[]
        */
        @Column(name = "PAID_AMT")
        private BigDecimal paidAmt;
    
        /*
         汇率[]
        */
        @Column(name = "EXCHANGE_RATE")
        private BigDecimal exchangeRate;
    
        /*
         总笔数[
    ]
        */
        @Column(name = "TOTAL_NUM")
        private int totalNum;
    
        /*
         成功笔数[]
        */
        @Column(name = "SUS_NUM")
        private int susNum;
    
        /*
         失败笔数[]
        */
        @Column(name = "FAIL_NUM")
        private int failNum;
    
        /*
         付款账户[]
        */
        @Column(name = "PAY_ACC")
        private String payAcc;
    
        /*
         收支项目[预留
    ]
        */
        @Column(name = "PROJECT_BUDGET")
        private String projectBudget;
    
        /*
         资金计划[预留
    ]
        */
        @Column(name = "BUDGET_PLAN")
        private String budgetPlan;
    
        /*
         用途
    用途[]
        */
        @Column(name = "REMARK")
        private String remark;
    
        /*
         单据状态["00申请/待提交、01审批中、02审批退回、10受理中、11已受理、12财司退回
    20已办结、30已作废"
    ]
        */
        @Column(name = "BILL_STATUS")
        private String billStatus;
    
        /*
         经办人[]
        */
        @Column(name = "OPERATOR")
        private String operator;
    
        /*
         经办日期[]
        */
        @Column(name = "OPERATE_DATE")
        private String operateDate;
    
        /*
         柜面退回人[]
        */
        @Column(name = "BACKER")
        private String backer;
    
        /*
         柜面退回日期[]
        */
        @Column(name = "BACK_DATE")
        private String backDate;
    
        /*
         柜面退回原因[]
        */
        @Column(name = "BACK_REASON")
        private String backReason;
    
        /*
         对应柜台业务单号[]
        */
        @Column(name = "COUNTER_BILL_CODE")
        private String counterBillCode;
    
        /*
         时间戳[]
        */
        @Column(name = "TIME_STAMP")
        private String timeStamp;
    
        @Transient
        private List<Map> list;
    
        /*---------------------以下为变量getset方法区域----------------------------*/
        /*
         申请内码[YYYYMMDD+12位流水号
    ]
        */
        public void setApplyId(String applyId) {
            this.applyId = applyId;
        }
    
        /*
         申请内码[YYYYMMDD+12位流水号
    ]
        */
        public String getApplyId() {
            return this.applyId;
        }
    
        /*
         付款批号[预留
    ]
        */
        public void setBatchCode(String batchCode) {
            this.batchCode = batchCode;
        }
    
        /*
         付款批号[预留
    ]
        */
        public String getBatchCode() {
            return this.batchCode;
        }
    
        /*
         申请编号[]
        */
        public void setBznsCode(String bznsCode) {
            this.bznsCode = bznsCode;
        }
    
        /*
         申请编号[]
        */
        public String getBznsCode() {
            return this.bznsCode;
        }
    
        /*
         客户编号[]
        */
        public void setCustCode(String custCode) {
            this.custCode = custCode;
        }
    
        /*
         客户编号[]
        */
        public String getCustCode() {
            return this.custCode;
        }
    
        /*
         业务类型[对私批量业务类型
    ]
        */
        public void setBznsType(String bznsType) {
            this.bznsType = bznsType;
        }
    
        /*
         业务类型[对私批量业务类型
    ]
        */
        public String getBznsType() {
            return this.bznsType;
        }
    
        /*
         申请来源[申请来源:1-Excel导入、2-外部申请
    ]
        */
        public void setAppSource(String appSource) {
            this.appSource = appSource;
        }
    
        /*
         申请来源[申请来源:1-Excel导入、2-外部申请
    ]
        */
        public String getAppSource() {
            return this.appSource;
        }
    
        /*
         急缓标志[【客户选择,用以匹配发送方式,0-普通;1-加急】
    ]
        */
        public void setFastFlag(String fastFlag) {
            this.fastFlag = fastFlag;
        }
    
        /*
         急缓标志[【客户选择,用以匹配发送方式,0-普通;1-加急】
    ]
        */
        public String getFastFlag() {
            return this.fastFlag;
        }
    
        /*
         所属机构[目前默认为客户账户的机构
    ]
        */
        public void setOrgId(String orgId) {
            this.orgId = orgId;
        }
    
        /*
         所属机构[目前默认为客户账户的机构
    ]
        */
        public String getOrgId() {
            return this.orgId;
        }
    
        /*
         客户账户编号[]
        */
        public void setCustAccCode(String custAccCode) {
            this.custAccCode = custAccCode;
        }
    
        /*
         客户账户编号[]
        */
        public String getCustAccCode() {
            return this.custAccCode;
        }
    
        /*
         客户账户名称[冗余
    ]
        */
        public void setCustAccName(String custAccName) {
            this.custAccName = custAccName;
        }
    
        /*
         客户账户名称[冗余
    ]
        */
        public String getCustAccName() {
            return this.custAccName;
        }
    
        /*
         客户银行账号[]
        */
        public void setCustBankAcc(String custBankAcc) {
            this.custBankAcc = custBankAcc;
        }
    
        /*
         客户银行账号[]
        */
        public String getCustBankAcc() {
            return this.custBankAcc;
        }
    
        /*
         币种[]
        */
        public void setCurcd(String curcd) {
            this.curcd = curcd;
        }
    
        /*
         币种[]
        */
        public String getCurcd() {
            return this.curcd;
        }
    
        /*
         应付金额[]
        */
        public void setPayAmt(BigDecimal payAmt) {
            this.payAmt = payAmt;
        }
    
        /*
         应付金额[]
        */
        public BigDecimal getPayAmt() {
            return this.payAmt;
        }
    
        /*
         实付金额[]
        */
        public void setPaidAmt(BigDecimal paidAmt) {
            this.paidAmt = paidAmt;
        }
    
        /*
         实付金额[]
        */
        public BigDecimal getPaidAmt() {
            return this.paidAmt;
        }
    
        /*
         汇率[]
        */
        public void setExchangeRate(BigDecimal exchangeRate) {
            this.exchangeRate = exchangeRate;
        }
    
        /*
         汇率[]
        */
        public BigDecimal getExchangeRate() {
            return this.exchangeRate;
        }
    
        /*
         总笔数[
    ]
        */
        public void setTotalNum(int totalNum) {
            this.totalNum = totalNum;
        }
    
        /*
         总笔数[
    ]
        */
        public int getTotalNum() {
            return this.totalNum;
        }
    
        /*
         成功笔数[]
        */
        public void setSusNum(int susNum) {
            this.susNum = susNum;
        }
    
        /*
         成功笔数[]
        */
        public int getSusNum() {
            return this.susNum;
        }
    
        /*
         失败笔数[]
        */
        public void setFailNum(int failNum) {
            this.failNum = failNum;
        }
    
        /*
         失败笔数[]
        */
        public int getFailNum() {
            return this.failNum;
        }
    
        /*
         付款账户[]
        */
        public void setPayAcc(String payAcc) {
            this.payAcc = payAcc;
        }
    
        /*
         付款账户[]
        */
        public String getPayAcc() {
            return this.payAcc;
        }
    
        /*
         收支项目[预留
    ]
        */
        public void setProjectBudget(String projectBudget) {
            this.projectBudget = projectBudget;
        }
    
        /*
         收支项目[预留
    ]
        */
        public String getProjectBudget() {
            return this.projectBudget;
        }
    
        /*
         资金计划[预留
    ]
        */
        public void setBudgetPlan(String budgetPlan) {
            this.budgetPlan = budgetPlan;
        }
    
        /*
         资金计划[预留
    ]
        */
        public String getBudgetPlan() {
            return this.budgetPlan;
        }
    
        /*
         用途
    用途[]
        */
        public void setRemark(String remark) {
            this.remark = remark;
        }
    
        /*
         用途
    用途[]
        */
        public String getRemark() {
            return this.remark;
        }
    
        /*
         单据状态["00申请/待提交、01审批中、02审批退回、10受理中、11已受理、12财司退回
    20已办结、30已作废"
    ]
        */
        public void setBillStatus(String billStatus) {
            this.billStatus = billStatus;
        }
    
        /*
         单据状态["00申请/待提交、01审批中、02审批退回、10受理中、11已受理、12财司退回
    20已办结、30已作废"
    ]
        */
        public String getBillStatus() {
            return this.billStatus;
        }
    
        /*
         经办人[]
        */
        public void setOperator(String operator) {
            this.operator = operator;
        }
    
        /*
         经办人[]
        */
        public String getOperator() {
            return this.operator;
        }
    
        /*
         经办日期[]
        */
        public void setOperateDate(String operateDate) {
            this.operateDate = operateDate;
        }
    
        /*
         经办日期[]
        */
        public String getOperateDate() {
            return this.operateDate;
        }
    
        /*
         柜面退回人[]
        */
        public void setBacker(String backer) {
            this.backer = backer;
        }
    
        /*
         柜面退回人[]
        */
        public String getBacker() {
            return this.backer;
        }
    
        /*
         柜面退回日期[]
        */
        public void setBackDate(String backDate) {
            this.backDate = backDate;
        }
    
        /*
         柜面退回日期[]
        */
        public String getBackDate() {
            return this.backDate;
        }
    
        /*
         柜面退回原因[]
        */
        public void setBackReason(String backReason) {
            this.backReason = backReason;
        }
    
        /*
         柜面退回原因[]
        */
        public String getBackReason() {
            return this.backReason;
        }
    
        /*
         对应柜台业务单号[]
        */
        public void setCounterBillCode(String counterBillCode) {
            this.counterBillCode = counterBillCode;
        }
    
        /*
         对应柜台业务单号[]
        */
        public String getCounterBillCode() {
            return this.counterBillCode;
        }
    
        /*
         时间戳[]
        */
        public void setTimeStamp(String timeStamp) {
            this.timeStamp = timeStamp;
        }
    
        /*
         时间戳[]
        */
        public String getTimeStamp() {
            return this.timeStamp;
        }
    
        public String getOrgName() {
            return orgName;
        }
    
        public void setOrgName(String orgName) {
            this.orgName = orgName;
        }
    
        public List<Map> getList() {
            return list;
        }
    
        public void setList(List<Map> list) {
            this.list = list;
        }
    
        public String getCustName() {
            return custName;
        }
    
        public void setCustName(String custName) {
            this.custName = custName;
        }
    
    
        /*---------------------变量getset方法区域-结束----------------------------*/
    }
    package com.genersoft.enetbank.settlement.payapp.dao;
    
    import com.genersoft.enetbank.bill.recbill.common.BillReceiveComMethod;
    import com.genersoft.enetbank.combusi.SettlementConstant;
    import com.genersoft.enetbank.combusi.bean.Jssfdjb;
    import com.genersoft.enetbank.combusi.commonhelp.dao.CommonHelpDao;
    import com.genersoft.enetbank.common.ENBConstants;
    import com.genersoft.enetbank.common.UserInfo;
    import com.genersoft.enetbank.common.dao.GetSysConf;
    import com.genersoft.enetbank.common.dao.TsBaseJdbcDao;
    import com.genersoft.enetbank.common.dao.TsDaoFactory;
    import com.genersoft.enetbank.common.exception.TsException;
    import com.genersoft.enetbank.common.jszhzd.dao.Jszhzd;
    import com.genersoft.enetbank.common.utils.TsUtils;
    import com.genersoft.enetbank.common.utils.ValidateUtils;
    import com.genersoft.enetbank.common.workflow.TsWfUtils;
    import com.genersoft.enetbank.settlement.pubbean.BatchPay;
    import com.genersoft.enetbank.settlement.querystapp.dao.StSettlementApp;
    import com.genersoft.enetbank.settlement.stpublic.PubProduct;
    import org.loushang.next.data.*;
    import org.loushang.next.web.cmd.CommandContext;
    
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.math.BigDecimal;
    import java.util.*;
    import java.util.regex.Pattern;
    
    /**
     * <p>Description: </p>
     * <p>Create Date: 14-2-8</p>
     * <p>Copyright  : Genersoft Java Group(c)</p>
     *
     * @version 1.0
     */
    
      /* *************************************************************
     * Modifier  Date    Operate(AMD)   Description
    
     * ************************************************************/
    public class PayappDao  {
    
            public static void main(String[] args) throws IOException {
                BatchPay batchPay=new BatchPay();
                FileOutputStream fos=new FileOutputStream("F://MyTest.txt");
                ObjectOutputStream objectOutputStream=new ObjectOutputStream(fos);
                objectOutputStream.writeObject(batchPay);
                objectOutputStream.close();
            }
    
    }
  • 相关阅读:
    Cyclic Nacklace HDU
    Oulipo HDU
    Period HDU
    Blue Jeans POJ
    剪花布条 HDU
    最长公共前缀 CSU
    Clock Pictures CSU
    Number Sequence HDU
    Arrange the Bulls POJ
    Traveling by Stagecoach POJ
  • 原文地址:https://www.cnblogs.com/lidedong/p/9683035.html
Copyright © 2020-2023  润新知