我试图在一个文件夹TransactionReport(用户selectedDate)中创建一个文件(TranReport.pdf),但我面临一些问题。你能告诉我哪里做错了。
代码
try {
File pdfFolder = new File(
Environment.getExternalStorageDirectory() + "/"
+ "Android/AMSP/", "TransactionReport(" + date
+ ")");
if (!pdfFolder.exists()) {
pdfFolder.mkdir();
Log.i("", "Pdf Directory created");
}
File myFile = new File(pdfFolder, "TranReport" + ".pdf");
writer = PdfWriter.getInstance(document, new FileOutputStream(
myFile));
答案 0 :(得分:0)
通过更改pdfFolder.mkdir()可以解决问题; to pdfFolder.mkdirs();