开发者

Android writing to a CSV file via OpenCsv

开发者 https://www.devze.com 2023-01-12 09:51 出处:网络
I tr开发者_运维知识库y to write to a Csv file via: mFileWriter = new FileWriter( \"/sdcard/program/file\");

I tr开发者_运维知识库y to write to a Csv file via:

mFileWriter = new FileWriter(
        "/sdcard/program/file");

mCsvWriter = new CSVWriter(mFileWriter);

At the moment it throws an exception that the file doesn't exist. It's true that the file doesn't exist. What's the easiest way to create the file?


Does the FILE not exist, or the DIRECTORY it's supposed to go into?

If you want to create a directory structure, you can always do

File file = new File("/full/path/to/file");
file.mkdirs();

This will create any path leading up to this file that doesn't exist yet.

I suppose the missing quotes around your file name are a typo?

0

精彩评论

暂无评论...
验证码 换一张
取 消