这是我的文件的样子:
IDENTIFICATION::HARD::Should We appreciate Art?::Yes
MULTIPLECHOICE::HARD::Which of the FF is not an era of Art?::Bayutism::Digitalism,Somethingism,Retardism,Bayutism
IDENTIFICATION::HARD::What is Chris Browns Greatest Hit?::Rihanna
我正在阅读这样的文件
public void openQBankFile(){
try{
BufferedReader in = new BufferedReader(new FileReader(qbank.getAbsolutePath()));
String desc;
while((desc = in.readLine()) != null){
qbank_cont.add(desc);
}
in.close();
}catch(FileNotFoundException fnfe){
System.out.println("Question Repository Could Not Be Found");
return;
}catch(IOException ioe){
ioe.printStackTrace();
}
}
这是我获取arrayList内容的地方
public static void main(String[] args){
CreateQuiz cq = new CreateQuiz(new File("./quiz/HUM101.quiz"),new File("./qbank/HUM101.qbank"));
cq.openQBankFile();
cq.filterQuestions(3, "HARD");
System.out.println(cq.qbank_cont.get(0));
}
这就是我添加它的方式
public void filterQuestions(int numOfItems, String difficulty){
List<String> qt_diff = new ArrayList<String>();
for(int i = 0; i< qbank_cont.size();i++){
qt_diff.add(qbank_cont.get(i));
}
}
我会将它存储在一个arrayList
. 但是当我将它存储在 arraylist 中时,它只会插入整个文本。不是每行一行。(我正在使用arrayList.get(0)
)