项目策划书
题库管理系统
一.项目设计分析
该项目可以帮助莘莘学子寻找到需要的题目,同时可以打笔记使做题效率更高.
二.项目功能简介
<1>分级管理功能:该项目实现了管理员与用户的分离,管理员和用户权限不同.
<2>注册功能:用户在登陆界面可以进行账号的注册.
<3>修改用户信息功能:当用户或管理员登录系统时,可以完成自己的密码和昵称修改.
<4>查看题目功能:用户可根据类型和题目的序号对题目进行查看.
<5>记录笔记功能:当用户做题有所收获或见解时可以通过打笔记的方法记录自己的想法.
<6>删除笔记功能:防止自己打错笔记,避免不必要的资源浪费,同时使用户拥有一个较为整洁的笔记本.
<7>监察功能:管理员对用户的拥有增删改查的权力,防止恶意注册账号等
代码
实体
/** * @Author: Re * @Date: 2020/12/7 15:31 * 用户实体 */ public class User implements Comparable<User>{ private Integer id; private int level; private String password; private String userName; private int nodeCount; private String node; private int collectionCount; public String getUserName() { return userName; } public String getNode() { return node; } public void setNode(String node) { this.node = node; } public int getLevel() { return level; } public User() { } public User(Integer id) { this.id = id; } public User(Integer id,String password,String userName,int nodeCount,int collectionCount,int level) { this.id=id; this.password = password; this.userName = userName; this.level=level; this.nodeCount=nodeCount; this.collectionCount=collectionCount; } public int getId() { return id; } public void setId(Integer id) { this.id = id; } public String getPassword() { return password; } public int getNodeCount() { return nodeCount; } public void setNodeCount(int nodeCount) { this.nodeCount = nodeCount; } public int getCollectionCount() { return collectionCount; } public String getName() { return userName; } public void setName(String userName) { this.userName = userName; } @Override public String toString() { String s= (this.level==1)? "管理员":"用户"; return "账号为:" + this.id + ",用户名为: " + this.userName + ",身份: "+ s; } /** * 比较器,用于用户的排序 * @param o * @return */ @Override public int compareTo(User o) { if(this.getId()==o.getId()){ return this.getName().compareTo(o.getName()); }else if(this.getId()>o.getId()){ return 1; } return -1; } } import java.util.Objects; /** * @Author: Re * @Date: 2020/12/7 15:46 * 问题实体 */ public class Questions implements Comparable<Questions>{ private String content; private String type; private int sign; private String complexity; private String answer; public String getType() { return type; } public void setType(String type) { this.type = type; } public String getComplexity() { return complexity; } public String getAnswer() { return answer; } public void setAnswer(String answer) { this.answer = answer; } public Questions() { } public Questions(String content, String type, int sign, String complexity, String answer) { this.content = content; this.type = type; this.sign = sign; this.complexity = complexity; this.answer = answer; } public String getContent() { return content; } public int getSign() { return sign; } public void setSign(int sign) { this.sign = sign; } @Override public String toString() { return "序号:" + sign+ "--题目类型:" + type + "--难易程度:" + complexity+ "\n"+content+"?" ; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Questions questions = (Questions) o; return complexity == questions.complexity && Objects.equals(type, questions.type) && Objects.equals(sign, questions.sign); } /** * 比较器,用于题目的排序 * @param o * @return */ @Override public int compareTo(Questions o) { if(this.getSign()==o.getSign()){ return this.getType().compareTo(o.getType()); }else if(this.getSign()>o.getSign()){ return 1; }else { return -1; } } } import java.util.Date; /** * @Author: Re * @Date: 2020/12/7 17:55 * 笔记实体 */ public class Note implements Comparable<Note>{ private Date time; private String master; private Integer id; private Integer Count=0; private Integer sign=0; private String Content; public Note() { } public Note(String maser) { this.master = maser; } public int getSign() { return sign; } public void setSign(Integer sign) { this.sign = sign; } public Date getTime() { return time; } public void setTime(Date time) { this.time = time; } public String getMaster() { return master; } public int getCount() { return Count; } public Integer getId() { return id; } public String getContent() { return Content; } public void setId(Integer id) { this.id = id; } public Note( String master, Integer id, Integer count, Integer sign, String content) { this.master = master; this.id = id; Count = count; this.sign = sign; Content = content; } @Override public String toString() { return "笔记内容:"+getContent() + "\n 用户名:" + master + " 笔记数目:" + Count ; } /** * 用于存入笔记的排序 * @param o * @return */ @Override public int compareTo(Note o) { if(this.getId().equals(o.getId())){ return this.getSign()-o.getSign(); }else if(this.getId() > o.getId()){ return 1; } return -1; } }
Dao
接口
//用户dao层接口 import studio.lyl.questionbankmanagementsystem.entity.User; import java.util.List; /** * @Author: Re * @Date: 2020/12/7 16:23 */ public interface IUserDao { /** * 创建用户 * @param user * @return boolean */ boolean insertUser(User user) ; /** * 根据id删除用户 * @param id * @return boolean */ boolean deleteUserById(Integer id) ; /** * 修改用户信息 * @param id * @param user * @return boolean */ boolean updateUser(Integer id,User user) ; /** * 根据id查看用户信息 * @param id * @return List */ List<User> selectUserById(Integer id) ; /** * 查看所有用户信息 * @return * @throws Exception */ List<User> selectUser() ; } //题库dao层接口 import studio.lyl.questionbankmanagementsystem.entity.Questions; import java.util.List; /** * @Author: Re * @Date: 2020/12/7 17:15 */ public interface IQuestionDao{ /** * 增加题目 * @param questions * @return boolean */ boolean insetQuestion(Questions questions) throws Exception; /** * 根据序号删除题目 * @param sign * @param type * @return boolean */ boolean deleteQuestion(int sign,String type) throws Exception; /** * 根据序号删除题目 * @param sign * @param questions * @param type * @return */ boolean updateQuestion(int sign ,String type ,Questions questions) throws Exception; /** * 根据序号查看题目 * @param sign * @param type * @return String */ List<Questions> selectQuestion(int sign, String type) ; /** * 根据序号和类型查看一个题的答案 * @param sign * @param type * @return */ List<Questions> selectAnswer(int sign,String type) ; /** * 查看一个类型里所有的题目 * @param type * @return List * @throws Exception */ List<Questions> selectQuestions(String type) ; } //笔记dao层窗口 import studio.lyl.questionbankmanagementsystem.entity.Note; import java.util.List; /** * @Author: Re * @Date: 2020/12/7 18:13 */ public interface INoteDao { /** * 增加笔记 * @param note * @return boolean */ boolean insetNote(Note note) ; /** * 根据用户id删除笔记 * @param id * @return boolean */ boolean deleteNote(Integer id,Integer sign) ; /** * 根据用户id更改笔记 * @param id * @param note * @param sign * @return */ boolean updateNote(Integer id,Integer sign,Note note) ; /** * 根据用户id查看笔记 * @param id * @return */ List<Note> selectNoteById(Integer id) ; /** * 查看所有的笔记 * @return */ List<Note> selectNote() ; }
实现接口
//用户dao层接口实现 ```import studio.lyl.questionbankmanagementsystem.dao.IUserDao; import studio.lyl.questionbankmanagementsystem.entity.User; import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @Author: Re * @Date: 2020/12/8 22:12 */ public class UserDaoImpl implements IUserDao { @Override public boolean insertUser(User user) { try { BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\User.txt",true)); String returnString=String.format("%s,%s,%s,%s,%s,%s",user.getId(),user.getPassword(),user.getUserName(),0,0,0); bufferedWriter.write(returnString); bufferedWriter.newLine(); bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } return false; } @Override public boolean deleteUserById(Integer id) { BufferedReader bufferedReader= null; try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\User.txt")); List<User> userList=new ArrayList<>(); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); User user=new User(Integer.parseInt(strings[0]),strings[1],strings[2],Integer.parseInt(strings[3]),Integer.parseInt(strings[4]),Integer.parseInt(strings[5])); userList.add(user); } for (int i = 0; i < userList.size(); i++) { User userGet=userList.get(i); if(userGet.getId()==id) { userList.remove(i); } } Collections.sort(userList); BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\User.txt")); for (int i = 0; i < userList.size(); i++) { User user=userList.get(i); String returnString=String.format("%s,%s,%s,%s,%s,%s",user.getId(),user.getPassword(),user.getUserName(),user.getNodeCount(),user.getCollectionCount(),user.getLevel()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedReader.close(); bufferedWriter.flush(); bufferedReader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return false; } @Override public boolean updateUser(Integer id,User user) { BufferedReader bufferedReader= null; try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\User.txt")); List<User> userList=new ArrayList<>(); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); User userGet=new User(Integer.parseInt(strings[0]),strings[1],strings[2],Integer.parseInt(strings[3]),Integer.parseInt(strings[4]),Integer.parseInt(strings[5])); userList.add(userGet); } for (int i = 0; i < userList.size(); i++) { User userGet=userList.get(i); if(userGet.getId()==id) { userList.set(i,user); } } Collections.sort(userList); BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\User.txt")); for (int i = 0; i < userList.size(); i++) { User userGet=userList.get(i); String returnString=String.format("%s,%s,%s,%s,%s,%s",userGet.getId(),userGet.getPassword(),userGet.getUserName(),userGet.getNodeCount(),userGet.getCollectionCount(),userGet.getLevel()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedReader.close(); bufferedWriter.flush(); bufferedReader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return false; } @Override public List<User> selectUserById(Integer id) { BufferedReader bufferedReader= null; List<User> returnUserList=new ArrayList<>(); try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\User.txt")); List<User> userList=new ArrayList<>(); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); User user=new User(Integer.parseInt(strings[0]),strings[1],strings[2],Integer.parseInt(strings[3]),Integer.parseInt(strings[4]),Integer.parseInt(strings[5])); userList.add(user); } for (int i = 0; i < userList.size(); i++) { User user=userList.get(i); if(user.getId()==id){ returnUserList.add(user); } } Collections.sort(returnUserList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return returnUserList; } @Override public List<User> selectUser() { BufferedReader bufferedReader= null; List<User> userList=new ArrayList<>(); try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\User.txt")); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); User user=new User(Integer.parseInt(strings[0]),strings[1],strings[2],Integer.parseInt(strings[3]),Integer.parseInt(strings[4]),Integer.parseInt(strings[5])); userList.add(user); } Collections.sort(userList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return userList; } } //题库dao层实现 import studio.lyl.questionbankmanagementsystem.dao.IQuestionDao; import studio.lyl.questionbankmanagementsystem.entity.Questions; import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @Author: Re * @Date: 2020/12/8 20:18 */ public class QuestionDaoImpl implements IQuestionDao { @Override public boolean insetQuestion(Questions questions) { BufferedWriter bufferedWriter= null; try { bufferedWriter = new BufferedWriter(new FileWriter(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+questions.getType()+".txt",true)); bufferedWriter.write(questions.getContent()+","+questions.getType()+","+questions.getSign()+","+questions.getComplexity()+","+questions.getAnswer()); bufferedWriter.newLine(); bufferedWriter.flush(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public boolean deleteQuestion(int sign,String type) { BufferedReader bufferedReader= null; BufferedWriter bufferedWriter=null; try { bufferedReader = new BufferedReader(new FileReader(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); List<Questions> questionsList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Questions questions=new Questions(strings[0],strings[1],Integer.parseInt(strings[2]),strings[3],strings[4]); questionsList.add(questions); } for (int i = 0; i < questionsList.size(); i++) { Questions questions=questionsList.get(i); if(questions.getSign()==sign){ questionsList.remove(i); } } Collections.sort(questionsList); bufferedWriter=new BufferedWriter(new FileWriter(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); for (int i = 0; i < questionsList.size(); i++) { Questions questions=questionsList.get(i); String returnString=String.format("%s,%s,%s,%s,%s",questions.getContent(),questions.getType(),questions.getSign(),questions.getComplexity(),questions.getAnswer()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedWriter.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public boolean updateQuestion(int sign,String type,Questions questions) { BufferedReader bufferedReader= null; BufferedWriter bufferedWriter=null; try { bufferedReader = new BufferedReader(new FileReader(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); List<Questions> questionsList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Questions questionsSet=new Questions(strings[0],strings[1],Integer.parseInt(strings[2]),strings[3],strings[4]); questionsList.add(questionsSet); } for (int i = 0; i < questionsList.size(); i++) { Questions questionsSet=questionsList.get(i); if(questionsSet.getSign()==sign){ questionsList.set(i,questions); } } Collections.sort(questionsList); bufferedWriter=new BufferedWriter(new FileWriter(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); for (int i = 0; i < questionsList.size(); i++) { Questions questionsSet=questionsList.get(i); String returnString=String.format("%s,%s,%s,%s,%s",questionsSet.getContent(),questionsSet.getType(),questionsSet.getSign(),questionsSet.getComplexity(),questionsSet.getAnswer()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedWriter.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public List<Questions> selectQuestion(int sign,String type) { BufferedReader bufferedReader= null; List<Questions> returnQuestionsList=new ArrayList<>(); try { bufferedReader = new BufferedReader(new FileReader(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); List<Questions> questionsList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Questions questions=new Questions(strings[0],strings[1],Integer.parseInt(strings[2]),strings[3],strings[4]); questionsList.add(questions); } for (int i = 0; i < questionsList.size(); i++) { Questions questions=questionsList.get(i); if(questions.getSign()==sign){ for (int j = 0; j < questionsList.size(); j++) { returnQuestionsList.add(questions); } } } Collections.sort(returnQuestionsList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return returnQuestionsList; } @Override public List<Questions> selectAnswer(int sign, String type) { BufferedReader bufferedReader= null; try { bufferedReader = new BufferedReader(new FileReader(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); List<Questions> questionsList=new ArrayList<>(); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Questions questions=new Questions(strings[0],strings[1],Integer.parseInt(strings[2]),strings[3],strings[4]); questionsList.add(questions); } for (int i = 0; i < questionsList.size(); i++) { Questions questions=questionsList.get(i); if(questions.getSign()==sign){ System.out.println(questions.getAnswer()); } } Collections.sort(questionsList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return null; } @Override public List<Questions> selectQuestions(String type) { BufferedReader bufferedReader=null; List<Questions> questionsList=null; try { bufferedReader = new BufferedReader(new FileReader(("QuestionBankManagementSystem\\Questions\\".endsWith("/") ? "QuestionBankManagementSystem\\Questions\\":"QuestionBankManagementSystem\\Questions\\"+"/")+type+".txt")); questionsList=new ArrayList<>(); String s=null; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Questions questions=new Questions(strings[0],strings[1],Integer.parseInt(strings[2]),strings[3],strings[4]); questionsList.add(questions); } Collections.sort(questionsList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return questionsList; } } //笔记dao层实现 import studio.lyl.questionbankmanagementsystem.dao.INoteDao; import studio.lyl.questionbankmanagementsystem.dao.IUserDao; import studio.lyl.questionbankmanagementsystem.entity.Note; import studio.lyl.questionbankmanagementsystem.entity.User; import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @Author: Re * @Date: 2020/12/8 8:37 */ public class NoteDaoImpl implements INoteDao { @Override public boolean insetNote(Note note) { BufferedWriter bufferedWriter= null; IUserDao iUserDao=new UserDaoImpl(); try { List<User> userList=iUserDao.selectUserById(note.getId()); User user=userList.get(0); user.setNodeCount(user.getCollectionCount()+1); bufferedWriter = new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\Note.txt",true)); bufferedWriter.write(note.getMaster()+","+note.getId()+","+note.getCount()+","+note.getSign()+","+note.getContent()); bufferedWriter.newLine(); bufferedWriter.flush();; } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public boolean deleteNote(Integer id,Integer sign) { BufferedReader bufferedReader= null; BufferedWriter bufferedWriter=null; try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\Note.txt")); List<Note> noteList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Note note=new Note(strings[0],Integer.parseInt(strings[1]),Integer.parseInt(strings[2]),Integer.parseInt(strings[3]),strings[4]); noteList.add(note); } bufferedWriter=new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\Note.txt")); for (int i = 0; i < noteList.size(); i++) { Note note=noteList.get(i); if(note.getId().equals(id)){ if (note.getSign()==sign){ noteList.remove(i); } } } Collections.sort(noteList); for (int i = 0; i < noteList.size(); i++) { Note note=noteList.get(i); String returnString=String.format("%s,%s,%s,%s,%s",note.getMaster(),note.getId(),note.getCount(),note.getSign(),note.getContent()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedWriter.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public boolean updateNote(Integer id,Integer sign,Note note) { BufferedReader bufferedReader= null; BufferedWriter bufferedWriter=null; try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\Note.txt")); List<Note> noteList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Note noteGet=new Note(strings[0],Integer.parseInt(strings[1]),Integer.parseInt(strings[2]),Integer.parseInt(strings[3]),strings[4]); noteList.add(noteGet); } bufferedWriter=new BufferedWriter(new FileWriter("QuestionBankManagementSystem\\Note.txt")); for (int i = 0; i < noteList.size(); i++) { Note noteSet=noteList.get(i); if(noteSet.getId().equals(id)) { if(noteSet.getSign()==sign) { noteList.set(sign-1, note); } } } Collections.sort(noteList); for (int i = 0; i < noteList.size(); i++) { Note returnNote=noteList.get(i); String returnString = String.format("%s,%s,%s,%s,%s", returnNote.getMaster(), returnNote.getId(), returnNote.getCount(), returnNote.getSign(), returnNote.getContent()); bufferedWriter.write(returnString); bufferedWriter.newLine(); } bufferedWriter.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedWriter.close(); } catch (IOException e) { e.printStackTrace(); } try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } @Override public List<Note> selectNoteById(Integer id) { BufferedReader bufferedReader= null; List<Note> returnNoteList=new ArrayList<>(); try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\Note.txt")); List<Note> noteList=new ArrayList<>(); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Note note=new Note(strings[0],Integer.parseInt(strings[1]),Integer.parseInt(strings[2]),Integer.parseInt(strings[3]),strings[4]); noteList.add(note); } for (int i = 0; i < noteList.size(); i++) { Note note=noteList.get(i); if(note.getId().equals(id)){ returnNoteList.add(note); } } Collections.sort(returnNoteList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return returnNoteList; } @Override public List<Note> selectNote() { BufferedReader bufferedReader= null; List<Note> noteList=new ArrayList<>(); try { bufferedReader = new BufferedReader(new FileReader("QuestionBankManagementSystem\\Note.txt")); String s; while ((s=bufferedReader.readLine())!=null){ String[] strings=s.split(","); Note note=new Note(strings[0],Integer.parseInt(strings[1]),Integer.parseInt(strings[2]),Integer.parseInt(strings[3]),strings[4]); noteList.add(note); } Collections.sort(noteList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return noteList; } }