0
타임 스탬프를 이름으로 사용하여 파일을 저장하려고합니다. 내가 직접 파일 이름을 지을 때 파일을 저장할 수 있지만 타임 스탬프를 사용하려고하면 파일이 작동하지 않습니다. 내 코드는 다음과 같습니다.타임 스탬프를 사용하여 파일 저장
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
File newxmlfile = new File(Environment.getExternalStorageDirectory()
+ ts);
try {
newxmlfile.createNewFile();
} catch (IOException e) {
Log.e("IOException", "exception in createNewFile() method");
}
FileOutputStream fileos = null;
try {
fileos = new FileOutputStream(newxmlfile);
} catch (FileNotFoundException e) {
Log.e("FileNotFoundException", "can't create FileOutputStream");
}
이 작업을 수행하는 방법을 아는 사람이 있습니까?
EDIT (SOLVED) : 아래 줄을 변경하고 타임 스탬프를 사용하여 XML 파일로 파일을 저장했습니다.
File newxmlfile = new File(Environment.getExternalStorageDirectory()
,ts + ".xml");
오류가 발생 했습니까? –
-1 "작동하지 않음"을 정의하지 않았습니다. – njzk2