为了账号安全,请及时绑定邮箱和手机立即绑定

为什么会一直提示java.io.NotSerializableException: imooc.playlist.PlayList错误呢?

为什么会一直提示java.io.NotSerializableException: imooc.playlist.PlayList错误呢?

沫沫Michelle 2017-09-13 17:12:19
PlayList类和Song类都已经继承了序列化接口啊:    public class PlayList implements Serializable    public class Song implements Serializable主程序中的代码:case 8: System.out.println("导出歌单 "); System.out.println("请输入要导出的歌曲列表名称: "); instr = scanner.next(); String fileName = instr + "的歌单.txt"; if (playListCollection.searchPlayListByName(instr) != null) { PlayList sPlayList = playListCollection.searchPlayListByName(instr); try { FileOutputStream fos = new FileOutputStream(fileName); ObjectOutputStream oos = new ObjectOutputStream(fos); FileInputStream fis = new FileInputStream(fileName); ObjectInputStream ois = new ObjectInputStream(fis); // 写入对象// oos.writeObject(sPlayList); Iterator<Song> it = sPlayList.getMusicList().iterator(); while (it.hasNext()) { oos.writeObject(it.next()); } oos.flush(); // 读对象信息 try { PlayList rPlayList = (PlayList) ois.readObject(); System.out.println(rPlayList); } catch (ClassNotFoundException e) { e.printStackTrace(); } oos.close(); fos.close(); ois.close(); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } PlayListMenu(); break;
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 5128 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信