如何解决Java.io.FileOutputStream是Google App Engine中的受限类

如何解决Java.io.FileOutputStream是Google App Engine中的受限类,java,google-app-engine,Java,Google App Engine,我使用的是Netbeans、谷歌应用程序引擎、java。当我尝试按如下方式创建pdf时,它会显示此错误 Java.io.FileOutputStream是Google应用程序引擎中的受限类。 我的密码是 Document document = new Document(); PdfWriter.getInstance(document, new BufferedOutputStream(new FileOutputStream("C:\\Examplenamaaaa.pdf"))); doc

我使用的是Netbeans、谷歌应用程序引擎、java。当我尝试按如下方式创建pdf时,它会显示此错误

Java.io.FileOutputStream是Google应用程序引擎中的受限类。

我的密码是

Document document = new Document();

PdfWriter.getInstance(document, new BufferedOutputStream(new FileOutputStream("C:\\Examplenamaaaa.pdf")));

document.open();

PdfPTable table = new PdfPTable(2);

PdfPCell cell = new PdfPCell(new Paragraph("column span 2"));
cell.setColspan(2);

table.addCell(cell);

table.addCell("1");

table.addCell("Namita");

table.addCell("2");

table.addCell("Asmita");

document.add(table);

document.close();

您正在编写在C-drive上创建PDF文件的代码。虽然这可以在你的机器上运行,但在谷歌应用程序引擎上可能不会

相反,您可以尝试将PDF写入(例如),然后将其发送回web浏览器,以便能够查看生成的PDF

ByteArrayOutputStream
的行为与
FileOutputStream
的行为完全相同,只是字节不是写入文件,而是写入
byte[]
(因此得名)。它们都扩展了接口,因此可以在不进一步更改代码的情况下切换它们


将响应流回浏览器,以便您可以考虑存储<代码> BytRayRayOutsStuts中的内容,以便稍后再将其送回浏览器。

参见MthMuldDS,但不知道如何使用BytTayRayOutsStudio。如果你想在线保存PDF文件,你可能还想看看。