Java实验报告模版 联系客服

发布时间 : 星期三 文章Java实验报告模版更新完毕开始阅读6b7b0265680203d8cf2f248d

实验十

实验名称: 综合项目设计 成绩:

实验目的和要求

1. 本实验属于综合性实验,要求学生自行设计一个小规模的信息管理实用软件。通过本实验培养学生分析问题与解决问题的能力以及创新能力。 2. 掌握面向对象的编程方法。

3. 掌握通过继承派生新类的方法、文件的输入及输出等操作。

4. 技术上尽量覆盖Java技术应用的数据库编程领域、网络编程领域。

5. 程序要实现以下功能:显示信息、查询信息、增加信息、删除信息、修改信息、读取信息、保存信息、退出程序等。

6. 系统界面要求:要求系统具有友好的用户界面,界面简洁、操作方便;

实验内容

1. 所设计开发软件名称及功能描述 2. 主要代码(最多粘贴5页) 3. 主要界面截图

import java.io.BufferedOutputStream; import java.io.File;

import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner;

public class AddList {

private String filePath = \ private String bakPath = \ private String content = \

Scanner sc = new Scanner(System.in);

public String readFile(){ content = \

if (isNull(filePath)) {

System.out.println(\文件存储路径:\ filePath = sc.nextLine(); }

File file = new File(filePath); FileReader fr = null; try {

if (file.exists()) {

fr = new FileReader(file); char[] chars = new char[1024]; int n = 0;

while((n = fr.read(chars)) != -1){

String string = new String(chars, 0, n); content = content + string; }

} else {

System.out.println(\文件不存在\ }

} catch (Exception e) { e.printStackTrace();

} finally {

if (fr != null) { try {

fr.close();

} catch (IOException e) { e.printStackTrace(); } } }

return content; }

public void writeFile(String path){ File file = new File(path); FileOutputStream fos = null; mkDirs(path); try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos); PrintWriter pw = new PrintWriter(bos, true); pw.print(content); pw.flush();

} catch (FileNotFoundException e) { e.printStackTrace(); } finally {

if (fos != null) { try {

fos.close();

} catch (IOException e) { e.printStackTrace(); } } } }

public void writeFile(){ if (isNull(filePath)) {

System.out.println(\文件存储路径:\ filePath = sc.nextLine(); }

File file = new File(filePath); FileOutputStream fos = null; mkDirs(filePath); try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos); PrintWriter pw = new PrintWriter(bos, true); pw.print(content); pw.flush();

} catch (FileNotFoundException e) { e.printStackTrace(); } finally {

if (fos != null) { try {

fos.close();

} catch (IOException e) { e.printStackTrace(); } } } }

public void mkDirs(String filepath){ if (filepath.indexOf(\

filepath = filepath.replaceAll(\ }

int n = filepath.indexOf(\

String path = filepath.substring(0, n) + \

filepath = filepath.substring(filepath.indexOf(\filepath.length());

String[] files = filepath.split(\

for (int i = 0; i < files.length - 1; i++) { path = path + files[i]; File file = new File(path); if (!file.exists()) { file.mkdir(); } } }

public void addImfor(){

System.out.println(\增加记录---------\ String name = \ String tel = \ String email = \ content = readFile(); while(true){

System.out.println(\姓名:\

+ 1,