Java把double数据写入文件中

该Java代码实现了一个名为ReadOrWriteObject的类,用于读取和写入double类型的数据到文件中。类中包含打开文件、关闭文件、刷新缓冲区、写入double数据和读取double数据的方法。在main方法中展示了如何使用该类进行数据的写入和读取。
摘要由CSDN通过智能技术生成
public class ReadOrWriteObject {
 
    private FileInputStream fileIns = null ;//文件输入流
    private FileOutputStream   fileOts = null;//文件输出流
    private ObjectInputStream  objectIns = null ;//对象输入流
    private ObjectOutputStream objectOts = null ;//对象输出流
    private String fileName = null;//待处理的文件名
    public static Boolean FileRead = true ;
    public static Boolean FileWrite = false ;
 
    /**
     *
     * @param fileName:文件名
     */
    public ReadOrWriteObject(String fileName){
        this.fileName = fileName ;
    }
     
    /**
     * 创建对象之后,首先必须以某种方式打开文件,如读的方式,或者写的方式
     * @param fileName: The name of the file.
     * @param bool: Whether the file read or write.如 FileRead or FileWrite
     * @return
     */
    public Boolean openFile(Boolean bool){
         
        if(bool)//if bool is true,the file is read.
        {
            try {
                this.fileIns = n
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值