2020.03.01 驾考练习题

 

public void makeChoiceSubject(){
BufferedReader reader=null;
String temp="";
try {
reader=new BufferedReader(new FileReader("E:/JAVA/新建文件夹/subject/choice.txt"));
int i=0;
ChoiceBean choiceBean=null;
while ((temp=reader.readLine())!=null){
if(i==0){
choiceBean=new ChoiceBean();
choiceBean.subject=temp;
}else if(i>0&&i<=4){
choiceBean.choice.add(temp);
}else if(i==5){
choiceBean.answer=temp;
}else{
db.choicelist.add(choiceBean);
}
i++;
if(i==7){
i=0;
}

}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void makeDetectSubject(){
BufferedReader reader=null;
String temp="";
try {
reader=new BufferedReader(new FileReader("E:/JAVA/新建文件夹/subject/detect.txt"));
int i=0;
DetectBean detect=null;
while ((temp=reader.readLine())!=null){
if(i==0){
detect=new DetectBean();
detect.subject=temp;
}else if(i==1){
detect.answer=temp;
}else{
db.detectlist.add(detect);
}
i++;
if(i==3){
i=0;
}

}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
posted @ 2020-03-01 21:50  ByLir  阅读(200)  评论(0)    收藏  举报