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");
}
有没有人知道如何做到这一点?
编辑(求助):我改变了下面的行,它使用时间戳保存文件作为一个XML文件。
File newxmlfile = new File(Environment.getExternalStorageDirectory()
,ts + ".xml");
你得到了哪个错误? – 2013-03-06 14:02:00
-1不定义“不起作用” – njzk2 2013-03-06 14:02:50