public
void
saveText() {
try
{
String path = Environment.getExternalStorageDirectory()+
"/serial"
;
File file =
new
File(path);
if
(!file.exists())
file.mkdirs();
file =
new
File(file,
"data.txt"
);
FileOutputStream fileOutputStream =
new
FileOutputStream(file,
true
);
String msg =
"테스트용 파일입니다."
;
fileOutputStream.write(msg.getBytes());
fileOutputStream.close();
Toast.makeText(
this
,
"Save Success"
, Toast.LENGTH_LONG).show();
}
catch
(FileNotFoundException fnfe){
Toast.makeText(
this
,
"지정된 파일을 생성할 수 없습니다."
,Toast.LENGTH_LONG).show();
}
catch
(IOException ioe) {
Toast.makeText(
this
,
"파일에 데이터를 쓸 수 없습니다."
, Toast.LENGTH_SHORT).show();}
}