I am trying to create a new CSV file then write to it, the code gets to as far as the BufferedWriter
then I get a java.io.FileNotFoundException: /mnt/sdcard/SMSMonitor/04-07-2011/Backup_20:43:00.csv (Invalid argument)
exception. Does anyone know why this is happening?
public void generateCSVFile(ArrayList<String> list)
{
File CreateDirectory = new File(Environment.getExternalStorageDirectory()
+ "/SMSMonitor/" + subFolderName);
CreateDirectory.mkdirs();
try
{
File file = new File(CreateDirectory +"/"+ fileName);
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write("ID, Date, Address, Body");
writer.newLine();
for (String s : list)
{
writer.write(s);
writer.newLine();
}
writer.newLine();
writer.flush();
writer.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}开发者_运维百科
Try create the file without any colons, as the file system used has it reserved.
See http://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table
精彩评论