📄 scoreintosco.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -