FileOutputStream拒绝访问

在新建一个pdf文件时候遇到如下问题

Document document = new Document(PageSize.A4,50,50,50,50);
PdfWriter pdfWriter= PdfWriter.getInstance(document, new FileOutputStream("E:/pdf"));
document.open();
document.add(new Paragraph("Hello world"));
document.close();

java.io.FileNotFoundException: D:\xxx\yyy (拒绝访问。)


解决办法是将文件名字也写上去

PdfWriter pdfWriter= PdfWriter.getInstance(document, new FileOutputStream("E:/pdf/a.pdf"));

你可能感兴趣的:(FileOutputStream拒绝访问)