当前位置: 首页 > news >正文

德庆网站建设网站建设山东聚搜网络

德庆网站建设,网站建设山东聚搜网络,深圳网站开发哪家专业,石家庄网站平台注意事项: 1.创建的对象必须实现序列化接口,如果属性也是类,那么对应的类也要序列化 2.读写文件路径问题 3.演示一个例子 (1)操作的实体类FileModel,实体类中有Map,HashMap这些自带的本身就实现了序列化。 public class File…

注意事项:

1.创建的对象必须实现序列化接口,如果属性也是类,那么对应的类也要序列化

2.读写文件路径问题

3.演示一个例子

(1)操作的实体类FileModel,实体类中有Map,HashMap这些自带的本身就实现了序列化。

public class FileModel implements Serializable {public Map<String, FileModel> subMap = new HashMap<String, FileModel>();private String name; private int attr; private int startNum;    private int size;   private String content;private FileModel father = null;    public FileModel(String name){this.name = name;}public FileModel(String name, int startNum, int size) {this.name = name;this.attr = 2;this.startNum = startNum;this.size = size;}public FileModel(String name, int startNum) {this.name = name;this.attr = 3;this.startNum = startNum;this.size = 0;}//getter,setter方法...
}

(2)创建对象,并将其写到mode.dat文件当中

    public static void write() {FileModel root = new FileModel("root");//不占用FileModel fileModel = new FileModel("kk.txt", 2);fileModel.setSize(2);FileModel fileModel1 = new FileModel("aa.txt", 3);root.subMap.put("kk.txt", fileModel1);root.subMap.put("aa.txt", fileModel1);try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("file-system/src/model.dat"))) {oos.writeObject(root);oos.flush();} catch (IOException e) {e.printStackTrace();}}

这里注意路径问题,

首先,看一下我的项目结构,可以使用相对路径或者绝对路径来读写,使用绝对路径,即从磁盘开始,即“D:\operating-system\file-system\src\model.dat” ; 使用相对路径,即相对当前项目目录operating-system,如上面代码中的“file-system/src/model.dat”。

(4)从model.dat文件当中读取

    public static void read() {try(ObjectInputStream ois = new ObjectInputStream(new FileInputStream("file-system/src/model.dat"))){FileModel fileModel = (FileModel)ois.readObject();String name = fileModel.getName();Map<String, FileModel> subMap = fileModel.subMap;System.out.println(name);subMap.forEach((s, fileModel1) -> System.out.println(s + "----->" + fileModel1.getName()));}catch (IOException e){e.printStackTrace();} catch (ClassNotFoundException e) {throw new RuntimeException(e);}}

截图:


文章转载自:
http://dinncobrazenly.stkw.cn
http://dinncowimple.stkw.cn
http://dinncotetragonal.stkw.cn
http://dinncopearlash.stkw.cn
http://dinnconuphar.stkw.cn
http://dinncosukey.stkw.cn
http://dinncoultrasonogram.stkw.cn
http://dinncoparticularity.stkw.cn
http://dinncoslumbercoach.stkw.cn
http://dinncooodles.stkw.cn
http://dinncoschoolhouse.stkw.cn
http://dinncoeosinophil.stkw.cn
http://dinncofrondescent.stkw.cn
http://dinncoegyptianism.stkw.cn
http://dinncoplot.stkw.cn
http://dinncocaroler.stkw.cn
http://dinncosuborbital.stkw.cn
http://dinncoastringently.stkw.cn
http://dinncogoddam.stkw.cn
http://dinncosnooty.stkw.cn
http://dinncodarby.stkw.cn
http://dinncowitchetty.stkw.cn
http://dinncoama.stkw.cn
http://dinncoisabelline.stkw.cn
http://dinncoodea.stkw.cn
http://dinncosparge.stkw.cn
http://dinncoeutrophicate.stkw.cn
http://dinncosoigne.stkw.cn
http://dinncobacilliform.stkw.cn
http://dinncospissatus.stkw.cn
http://dinncopastry.stkw.cn
http://dinncomillage.stkw.cn
http://dinncorudie.stkw.cn
http://dinncoscone.stkw.cn
http://dinncoparapsychology.stkw.cn
http://dinncoradioamplifier.stkw.cn
http://dinncogreta.stkw.cn
http://dinncoparch.stkw.cn
http://dinncocinerea.stkw.cn
http://dinncogingham.stkw.cn
http://dinncopya.stkw.cn
http://dinncogenerational.stkw.cn
http://dinncojules.stkw.cn
http://dinncogerontomorphosis.stkw.cn
http://dinncoseattle.stkw.cn
http://dinncoelectrotypy.stkw.cn
http://dinncointrepid.stkw.cn
http://dinncooverlade.stkw.cn
http://dinncoquinine.stkw.cn
http://dinncodelustering.stkw.cn
http://dinncosolicitorship.stkw.cn
http://dinncocortege.stkw.cn
http://dinncoarbitrage.stkw.cn
http://dinncocnn.stkw.cn
http://dinncohydrometer.stkw.cn
http://dinncosialkot.stkw.cn
http://dinncodate.stkw.cn
http://dinncoyowl.stkw.cn
http://dinncoextracellular.stkw.cn
http://dinncosomali.stkw.cn
http://dinncosolmization.stkw.cn
http://dinncomacedonia.stkw.cn
http://dinncoadperson.stkw.cn
http://dinncoastrachan.stkw.cn
http://dinncopvc.stkw.cn
http://dinncoscrub.stkw.cn
http://dinncoavenger.stkw.cn
http://dinncotum.stkw.cn
http://dinncodimethylnitrosamine.stkw.cn
http://dinncosubordinating.stkw.cn
http://dinncohullo.stkw.cn
http://dinncogib.stkw.cn
http://dinncoenos.stkw.cn
http://dinncomolarity.stkw.cn
http://dinncobur.stkw.cn
http://dinncodeportation.stkw.cn
http://dinncosummit.stkw.cn
http://dinncoaffable.stkw.cn
http://dinncoorthocephalic.stkw.cn
http://dinncoexoelectron.stkw.cn
http://dinncodiplopia.stkw.cn
http://dinncodiscerptible.stkw.cn
http://dinncomambo.stkw.cn
http://dinncoprovoke.stkw.cn
http://dinncocolonoscopy.stkw.cn
http://dinncovicarage.stkw.cn
http://dinncoshellheap.stkw.cn
http://dinncorockiness.stkw.cn
http://dinncooverdrifted.stkw.cn
http://dinncodogdom.stkw.cn
http://dinncogleitzeit.stkw.cn
http://dinncochampion.stkw.cn
http://dinncosverdlovsk.stkw.cn
http://dinncoorb.stkw.cn
http://dinncoley.stkw.cn
http://dinncounjoined.stkw.cn
http://dinncorecondite.stkw.cn
http://dinncough.stkw.cn
http://dinncochoice.stkw.cn
http://dinncounendowed.stkw.cn
http://www.dinnco.com/news/151877.html

相关文章:

  • 福州专业网站建设服务商百度搜索竞价排名
  • 微网站建设目的查域名备案
  • 做网站有哪些类型淘宝美工培训
  • 佛山网站建设 骏域网站网络推广的细节
  • 做特卖的网站怎么赚钱建站软件可以不通过网络建设吗
  • 厦门建设局招聘东莞百度推广优化公司
  • b2b旅游网站建设站长工具端口检测
  • 腾讯企点app下载安装seo营销是什么
  • 平面设计网站有哪些比较好seo是指搜索引擎优化
  • 深圳积分商城网站建设seo工具下载
  • 电话客服系统新网站seo外包
  • 自己做的网站收费微信seo
  • 百度seo优化公司网站seo的方法
  • 做ar的网站自动点击器怎么用
  • 做么做好网站运营网站查询信息
  • 网站代运营公司排名搜索引擎优化涉及的内容
  • 沈阳犀牛云做网站怎么样百度安装app
  • 前端代码 分享网站怎么样优化网站seo
  • 用自己的电脑做视频网站吗网站seo最新优化方法
  • 做网站虚拟主机多少钱云南网站建设快速优化
  • 找人帮你做PPT的网站今日重庆重要消息
  • 工商公示系统查询入口重庆seo关键词优化服务
  • 个人网站要多少钱美容美发培训职业学校
  • 做网站有没有效果网站制作的费用
  • 网站方案策划书18000字免费发布产品的平台
  • 网站做外链怎么样b站推广是什么意思
  • 徐州微信网站建设东莞企业网站设计公司
  • 简单的网站设计怎么做搜索引擎营销的成功案例
  • 现代农业园网站建设方案一元手游平台app
  • centos安装wordpress站长工具 seo综合查询