【发布时间】:2014-03-19 14:44:45
【问题描述】:
我想创建一个xml文件并将日期作为名称
//我在这里新建一个名为Date.xml的xml文件
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss");
String Date= df.format(c.getTime());
File newxmlfile = new File(Environment.getExternalStorageDirectory()+ "/"+Date+".xml");
try {
Log.v("CreateXML", "create file:" + 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 文件未创建,我收到该错误
E/(12438): 19-mars-2014 05:06:19 E/IOException(12438):createNewFile() 方法中的异常 E/FileNotFoundException(12438): 无法创建 FileOutputStream E/Exception(12438): 创建 xml 文件时出错
【问题讨论】: