이 코드를 사용하고 있습니다.안드로이드에서 한 줄씩 읽는 방법?
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("config.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((br.readLine()) != null) {
temp1 = br.readLine();
temp2 = br.readLine();
}
in.close();
}catch (Exception e){//Catch exception if any
Toast.makeText(getBaseContext(), "Exception", Toast.LENGTH_LONG).show();
}
Toast.makeText(getBaseContext(), temp1+temp2, Toast.LENGTH_LONG).show();
그러나 이것은 예외를 나타내며 temp1 및 temp2를 업데이트하지 않습니다.
당신이 2 개 개의 다른 변수 같은 줄을 저장 하시겠습니까? 아니면 그냥 temp1과 temp2의 마지막 두 줄을 저장하고 싶습니까? – SERPRO
두 개의 다른 변수에 파일의 처음 두 줄을 저장하고 싶습니다. – xkrlaix