嗨,例如,我需要从文本文件中读取第 3 行
我已经编写了这段代码,但是它读取了第一行:
public void GetFrom_Text(){
String []message=null;
BufferedReader br=null;
String name1, faculty1, deparment1, officeNumber1, officeHour1, email1, phone1;
long e;
try{
String sCurrentLine = null;
String next=" ";
br =new BufferedReader(new InputStreamReader(getAssets().open("ab.txt")));
sCurrentLine=br.readLine();
if(sCurrentLine!=null )
message=sCurrentLine.split(",");
name1=message[0];
faculty1=message[1];
deparment1=message[2];
officeNumber1=message[3];
phone1=message[4];
email1=message[5];
e=db2.insertRecord(faculty1,deparment1 ,name1 , officeNumber1,phone1,email1,"11-12");
}
catch (IOException e1){
e1.printStackTrace();
}finally{
try {
if (br !=null)br.close();
}catch (IOException ex){
ex.printStackTrace();
}
}