没有合适的资源?快使用搜索试试~ 我知道了~
首页图书管理系统java代码实现
图书管理系统java代码实现
5星 · 超过95%的资源 8 下载量 191 浏览量
更新于2023-10-19
评论 1
收藏 458KB PDF 举报
主要为大家详细介绍了java代码实现的图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
资源详情
资源评论
资源推荐
图书管理系统图书管理系统java代码实现代码实现
主要为大家详细介绍了java代码实现的图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了java实现图书管理系统的具体代码,供大家参考,具体内容如下
/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称: 《图书管理系统——java》
* 作 者: 刘江波
* 完成日期: 2012 年 3 月 1 日
* 版 本 号: v3.0
* 对任务及求解方法的描述部分
* 问题描述:
* 程序头部的注释结束
*/
文件包的建立情况:
BookDao.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.liu.dao;
import com.liu.po.BookBean;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author asus
*/
public class BookDAO {
// 写
public void writeBook(Map<Integer,BookBean >bookMap){
//
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream("F:\缓存区\book.txt");
oos = new ObjectOutputStream(fos);
oos.writeObject(bookMap);
//清空缓存区
oos.flush();
}
catch (FileNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
//异常级别高的在后边
catch (IOException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
finally{
try{
//先开后闭
oos.close();
fos.close();
}catch(IOException ex){
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE,null,ex);
}
}
}
//读
public Map<Integer,BookBean>readBook(){
FileInputStream fis = null;
ObjectInputStream ois = null;
Map<Integer, BookBean> map = null;
try {
fis = new FileInputStream("F:\缓存区\book.txt");
ois = new ObjectInputStream(fis);
map = (Map<Integer, BookBean>) ois.readObject();//出现异常进入catch
} catch (ClassNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
} catch (FileNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
//Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
//ex.printStackTrace();
map=new HashMap<Integer,BookBean>();//出现异常时,进行创建map
} finally{
try {
if(ois!=null){
ois.close();
}
if(fis!=null){
fis.close();
}
} catch (IOException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
}
return map;
}
}
TypeDao.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.liu.dao;
import com.liu.po.TypeBean;
import java.io.*;
import java.util.*;
import java.util.logging.*;
/**
*
* 对文件进行读和写操作
*/
public class TypeDAO {
// 写
public void writeType(Map<Integer,TypeBean >typeMap){
//
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream("F:\\缓存区\\type.txt");
oos = new ObjectOutputStream(fos);
oos.writeObject(typeMap);
//清空缓存区
oos.flush();
}
catch (FileNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
//异常级别高的在后边
catch (IOException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
finally{
try{
//先开后闭
oos.close();
fos.close();
}catch(IOException ex){
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE,null,ex);
}
}
}
//读
public Map<Integer,TypeBean>readType(){
FileInputStream fis = null;
ObjectInputStream ois = null;
Map<Integer, TypeBean> map = null;
try {
fis = new FileInputStream("F:\\缓存区\\type.txt");
ois = new ObjectInputStream(fis);
map = (Map<Integer, TypeBean>) ois.readObject();//出现异常进入catch
} catch (ClassNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
} catch (FileNotFoundException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
//Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
//ex.printStackTrace();
map=new HashMap<Integer,TypeBean>();//出现异常时,进行创建map
} finally{
try {
if(ois!=null){
ois.close();
}
if(fis!=null){
fis.close();
}
} catch (IOException ex) {
Logger.getLogger(TypeDAO.class.getName()).log(Level.SEVERE, null, ex);
}
}
return map;
}
}
BookBean.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.liu.po;
import java.io.Serializable;
/**
*
* @author asus
*/
public class BookBean implements Serializable{
private int id;
private String bookName;
private String bookType;
private String memo;
private String money;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the bookName
*/
public String getBookName() {
return bookName;
}
/**
* @param bookName the bookName to set
*/
public void setBookName(String bookName) {
this.bookName = bookName;
}
/**
* @return the bookType
*/
public String getBookType() {
return bookType;
}
/**
* @param bookType the bookType to set
*/
public void setBookType(String bookType) {
this.bookType = bookType;
}
/**
* @return the memo
*/
public String getMemo() {
return memo;
}
/**
* @param memo the memo to set
*/
public void setMemo(String memo) {
this.memo = memo;
}
/**
* @return the money
*/
public String getMoney() {
return money;
}
/**
* @param money the money to set
*/
public void setMoney(String money) {
this.money = money;
}
}
TypeBean.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.liu.po;
/**
*
* @author asus
*/
import java.io.Serializable;
public class TypeBean implements Serializable{
private int id;
private String typeName;
private String memo;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the typeName
*/
public String getTypeName() {
return typeName;
}
/**
* @param typeName the typeName to set
*/
public void setTypeName(String typeName) {
this.typeName = typeName;
}
/**
* @return the memo
*/
public String getMemo() {
return memo;
}
/**
* @param memo the memo to set
*/
public void setMemo(String memo) {
this.memo = memo;
剩余13页未读,继续阅读
weixin_38727825
- 粉丝: 3
- 资源: 900
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5