有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

拒绝java GWT访问以将文件保存在任何文件夹中

我正在使用这个tutorial将一个文件上载到我的GWT应用程序。此文件通过servlet上载,每次我希望保存文件或使用getInputStream读取文件时,我都会收到以下消息:

>;拒绝访问(“java.io.FilePermission”C:\Users\NESPRE~1\AppData\Local\Temp\poifiles“write”)

如何确保文件可以读取?谢谢

protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
{
...
 List<FileItem> items = upload.parseRequest(req);
 if (item.isFormField()) 
         continue;

String fileName = item.getName();
if (fileName != null) {
   fileName = FilenameUtils. getName(fileName);
}

File uploadedFile = new File(UPLOAD_DIRECTORY, fileName);
if (uploadedFile.createNewFile())  //throw the exception here

}

共 (0) 个答案