도서관에서 빌린 앱을 만드는 책을 대출해서 공부중입니다.
메모장어플인데요
1.아래 트라이캐치 구문을 사용한 이유가뭘까요?
2.그리고 캐치 부분이 비어있으면 그냥 가만히 있는건가요?
3. while((temp = bufferReader.readLine()) != null) {
columns.append(temp);
columns.append("\n");
}
그리고 이부분이 해석이 잘안되네요 ㅠㅠ
public void save() {
// 메모를 저장한다.
String memoText = memo.getText().toString();
File savefile = new File("sdcard/Download/memo.txt");
try {
FileOutputStream buf = new FileOutputStream(savefile);
buf.write(memoText.getBytes());
buf.close();
Toast.makeText(this,"save success", Toast.LENGTH_SHORT).show();
} catch (IOException e) {}
}
public void load() {
// 저장된 메모를 불러온다.
memo.setText("");
File loadPath = new File("sdcard/Download/memo.txt");
try {
FileInputStream files = new FileInputStream(loadPath);
BufferedReader bufferReader = new BufferedReader(new InputStreamReader (files));
StringBuffer columns = new StringBuffer();
String temp = "";
while((temp = bufferReader.readLine()) != null) {
columns.append(temp);
columns.append("\n");
}
memo.setText(columns.toString());
Toast.makeText(this,"load success", Toast.LENGTH_SHORT).show();
} catch (IOException e) {}
}
}