java基于命令行的学生成绩管理系统Word格式.docx

上传人:b****5 文档编号:17995141 上传时间:2022-12-12 格式:DOCX 页数:13 大小:19.50KB
下载 相关 举报
java基于命令行的学生成绩管理系统Word格式.docx_第1页
第1页 / 共13页
java基于命令行的学生成绩管理系统Word格式.docx_第2页
第2页 / 共13页
java基于命令行的学生成绩管理系统Word格式.docx_第3页
第3页 / 共13页
java基于命令行的学生成绩管理系统Word格式.docx_第4页
第4页 / 共13页
java基于命令行的学生成绩管理系统Word格式.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

java基于命令行的学生成绩管理系统Word格式.docx

《java基于命令行的学生成绩管理系统Word格式.docx》由会员分享,可在线阅读,更多相关《java基于命令行的学生成绩管理系统Word格式.docx(13页珍藏版)》请在冰豆网上搜索。

java基于命令行的学生成绩管理系统Word格式.docx

publicstaticvoidmain(String[]args)throwsException{

MainMenumainmenu=newMainMenu();

mainmenu.StartMenu();

}

}

classCreateFile{

CreateFile()throwsIOException{

Scanners=newScanner(System.in);

System.out.println("

Wheretocreate?

(D:

/aaa/...)"

);

StringCurrentDirectory=s.next();

Filefile=newFile(CurrentDirectory);

if(file.exists()){

System.out.println("

Enterthename:

"

StringName=s.next();

Filef=newFile(CurrentDirectory+File.separator+Name);

//实例化File类的对象

f.mkdir();

successtocreate!

}elseSystem.out.println("

thedirectoryisn'

texist!

classDeleteFile{

Filepath;

publicDeleteFile(Filepath){

this.path=path;

publicvoidDelete(Filepath){

Filefilelist[]=path.listFiles();

intlistlen=filelist.length;

for(inti=0;

i<

listlen;

i++){

if(filelist[i].isDirectory()){

Delete(filelist[i]);

}

else{

filelist[i].delete();

path.delete();

//删除当前目录

voidSuccess(){

Successtodelete!

!

:

classEnterDirectory{

EnterDirectory(Stringpath)throwsIOException{

Runtime.getRuntime().exec("

explorer.exe"

+path);

classListDirectory{

ListDirectory(Stringpath){

//Stringluj=null;

//路径

//如果dir不以文件分隔符结尾,自动添加文件分隔符

if(!

path.endsWith(File.separator)){

path=path+File.separator;

FiledirFile=newFile(path);

//如果dir对应的文件不存在,或者不是一个文件夹则退出

dirFile.exists()||(!

dirFile.isDirectory())){

System.out.println("

Listfailed!

cannotfindthedirectory:

+path);

//list方法返回该目录下的所有文件(包括目录)的文件名,文件名不含路径信息

System.out.println(path+"

containsbelowdirectoriseorfiles"

String[]files=dirFile.list();

for(inti=0;

i<

files.length;

i++){

System.out.println(files[i]);

}

classCopyFile{

CopyFile(Stringsource,Stringdest)throwsIOException{

Filein=newFile(source);

Fileout=newFile(dest);

FileInputStreaminFile=newFileInputStream(in);

FileOutputStreamoutFile=newFileOutputStream(out);

byte[]buffer=newbyte[1024];

inti=0;

while((i=inFile.read(buffer))!

=-1){

outFile.write(buffer,0,i);

}//endwhile

inFile.close();

outFile.close();

System.out.print("

Successtocopy!

classCopyDirectory{

publicvoidcopyFolder(StringoldPath,StringnewPath){

try{

(newFile(newPath)).mkdirs();

//如果文件夹不存在则建立新文件夹

Filea=newFile(oldPath);

String[]file=a.list();

Filetemp=null;

for(inti=0;

file.length;

i++){

if(oldPath.endsWith(File.separator)){

temp=newFile(oldPath+file[i]);

else{

temp=newFile(oldPath+File.separator+file[i]);

if(temp.isFile()){

FileInputStreaminput=newFileInputStream(temp);

FileOutputStreamoutput=newFileOutputStream(newPath+"

/"

+

(temp.getName()).toString());

byte[]b=newbyte[1024*5];

intlen;

while((len=input.read(b))!

=-1){

output.write(b,0,len);

output.flush();

output.close();

input.close();

if(temp.isDirectory()){//如果是子文件夹

copyFolder(oldPath+"

+file[i],newPath+"

+file[i]);

catch(Exceptione){

复制整个文件夹容操作出错"

e.printStackTrace();

publicvoidSuccess(){

Successtocopythedirectory!

classTestDES{

Keykey;

publicTestDES(){}

publicTestDES(Stringstr){

getKey(str);

//生成密匙

/**

*根据参数生成KEY

*/

publicvoidgetKey(StringstrKey){

try{

KeyGenerator_generator=KeyGenerator.getInstance("

DES"

_generator.init(newSecureRandom(strKey.getBytes()));

this.key=_generator.generateKey();

_generator=null;

catch(Exceptione){

thrownewRuntimeException("

ErrorinitializingSqlMapclass.Cause:

"

+e);

/*

*文件file进行加密并保存目标文件destFile中

*

*paramfile要加密的文件如c:

/test/srcFile.txt

*paramdestFile加密后存放的文件名如c:

/加密后文件.txt

publicvoidencrypt(Stringfile,StringdestFile)throwsException{//【具体用法见主函数】

Ciphercipher=Cipher.getInstance("

//cipher.init(Cipher.ENCRYPT_MODE,getKey());

cipher.init(Cipher.ENCRYPT_MODE,this.key);

InputStreamis=newFileInputStream(file);

OutputStreamout=newFileOutputStream(destFile);

CipherInputStreamcis=newCipherInputStream(is,cipher);

byte[]buffer=newbyte[1024];

intr;

while((r=cis.read(buffer))>

0){

out.write(buffer,0,r);

cis.close();

is.close();

out.close();

*文件采用DES算法解密文件

*paramfile已加密的文件如c:

**paramdestFile

*解密后存放的文件名如c:

/test/解密后文件.txt

publicvoiddecrypt(Stringfile,Stringdest)throwsException{

cipher.init(Cipher.DECRYPT_MODE,this.key);

OutputStreamout=newFileOutputStream(dest);

CipherOutputStreamcos=newCipherOutputStream(out,cipher);

while((r=is.read(buffer))>

=0){

cos.write(buffer,0,r);

cos.close();

voidDES()throwsException{

inuputencryptedpassword:

Scannerscan=newScanner(System.in);

Stringtd1=scan.nextLine();

//以上两行用来实现字符串的输入。

TestDEStd=newTestDES(td1);

//【对称加密的密码所在】

encrypt:

inuputsourcefileandtargetfile:

Stringsourcee=scan.next();

Stringtargete=scan.next();

td.encrypt(sourcee,targete);

//加密

encryptionisplete!

decrypt:

inuputdecryptionedpassword:

Scannerscanf=newScanner(System.in);

Stringtd2=scanf.nextLine();

TestDEStdd=newTestDES(td2);

Stringsourced=scan.next();

Stringtargetd=scan.next();

tdd.decrypt(sourced,targetd);

//解密

decryptionisplete"

}

classMainMenu{

voidStartMenu()throwsException{

Choosewhattodo:

'

1'

Createadirectory"

2'

Deleteadirectory"

3'

Enteradirectory"

4'

Listadirectory"

5'

Copyafile"

6'

Copyadirectory"

7'

Encryptafile"

0'

Exit"

Scanners=newScanner(System.in);

inta=s.nextInt();

while(true){

switch(a){

case1:

youchoose1"

newCreateFile();

break;

case2:

youchoose2"

inputthedirectorynamethatyouwanttodelete:

Filepathtodele=newFile(s.next());

if(pathtodele.exists()){

DeleteFileDeleteDirectory=newDeleteFile(pathtodele);

DeleteDirectory.Delete(DeleteDirectory.path);

DeleteDirectory.Success();

Cannotfindthedirectory:

+pathtodele);

break;

case3:

youchoose3"

inputthedirectorythatyouwanttoenter:

Stringpathtoenter=s.next();

newEnterDirectory(pathtoenter);

case4:

youchoose4"

inputthedirectorynamethatyouwanttolist:

Stringpathtolist=s.next();

newListDirectory(pathtolist);

case5:

youchoose5"

inputthesourcefileandthetargetfile:

Stringsourcef=s.next();

Stringdestf=s.next();

newCopyFile(sourcef,destf);

case6:

youchoose6"

CopyDirectorycopydirectory=newCopyDirectory();

inputthesourcedirectory:

Stringsourcedir=s.next();

inputthetargetdirectory:

Stringdestdir=s.next();

copydirectory.copyFolder(sourcedir,destdir);

copydirectory.Success();

case7:

youchoose7"

TestDEStestdes=newTestDES();

testdes.DES();

case0:

youchoosetoexit"

System.exit(0);

default:

error"

a=s.nextInt();

四、实验结果及分析和(或)源程序调试过程

备注:

1、教师在布置需撰写实验报告的实验前,应先将报告书上的“实验题目”、“实验性质”、“实验目的”、“实验项目容”等项目填写完成,然后再下发给学生。

2、教师在布置需撰写报告的实验项目时,应告知学生提交实验报告的最后期限。

3、学生应按照要求正确地撰写实验报告:

1)在实验报告上正确地填写“实验时间”、“实验地点”等栏目。

2)将实验所涉及的源程序文件容(实验操作步骤或者算法)填写在“实验过程或算法(源程序)”栏目中。

3)将实验所涉及源程序调试过程(输入数据和输出结果)或者实验的分析容填写在“实验结果及分析和(或)源程序调试过程”栏目中。

4)在实验报告页脚的“报告创建时间:

”处插入完成实验报告时的日期和时间。

5)学生将每个实验完成后,按实验要求的文件名通过网络提交(上载)到指定的服务器所规定的共享文件夹中。

每个实验一个电子文档,如果实验中有多个电子文档(如源程序或图形等),则用WinRAR压缩成一个压缩包文档提交,压缩包文件名同实验报告文件名(见下条)。

6)提交的实验报告电子文档命名为:

“组号(2位数字)年级(两位数字不要“级”字)专业(缩写:

计算机科学与技术专业(计科)、网络工程专业(网络)、信息安全专业(信息)、物联网工程(物联网))项目组成员(学号(八位数字))实验序号(一位数字).doc。

如第1组完成第1个Project,专业为“计算机科学与技术”专业,项目组成员有:

三(学号20115676),四(学号20115676),王五(学号20115676),完成的课程设计报告命名为:

01_10计科_20115676三_20115676四_20115676王五1.doc,以后几次实验的报告名称以此类推。

4、教师(或助教)在评价学生实验时,应根据其提交的其他实验相关资料(例如源程序文件等)对实验报告进行仔细评价。

评价后应完成的项目有:

1)在“成绩”栏中填写实验成绩。

每个项目的实验成绩按照五级制(优、良、中、及格、不及格)方式评分,实验总成绩则通过计算每个项目得分的平均值获得(平均值计算时需将五级制转换为百分制优=95、良=85、中=75、及格=65、不及格=55)。

2)在“教师评价”栏中用符号标注评价项目结果(用√表示正确,用×

表示错误,用≈表示半对半错)。

3)在“教师评价”栏中“评价教师签名”填写评价教师(或助教)。

将评价后的实验报告转换为PDF格式文件归档。

4)课程实验环节结束后,任课教师将自己教学班的实验报告文件夹进行清理。

在提交文件夹中,文件总数为实验次数×

教学班学生人数(如,教学班人数为90人,实验项目为5,其文件数为:

90×

5=450)。

任课教师一定要认真清理,总数相符,否则学生该实验项目不能得分。

最后将学生提交的实验报告刻光盘连同实验成绩一起放入试卷袋存档。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 艺术创意

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1