scoreintosco.java
来自「java编写的桌面考试系统.含所有源码.」· Java 代码 · 共 36 行
JAVA
36 行
package exam.dao;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
public class ScoreIntoSco implements ScoreDao {
public boolean addScore(int id, int score, String subject) {
FileOutputStream fos = null;
PrintWriter pw = null;
try {
fos = new FileOutputStream(new File(subject + ".sco"), true);
pw = new PrintWriter(fos);
pw.println(id + ":" + score);
pw.flush();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (pw != null) {
pw.close();
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?