将字节数据写入目录(访问被拒绝)

时间:2015-02-03 18:41:24

标签: java spring-mvc servlets directory

我尝试将字节数据写入Web应用程序目录我使用以下代码但是我收到此错误java.io.FileNotFoundException:C:\ Users \ user \ workspace.metadata.plugins \ org.eclipse.wst.server。 core \ tmp0 \ wtpwebapps \ pagingpoc(访问被拒绝)

        String appPath = request.getServletContext().getRealPath("");
        String savePath = appPath + File.separator ;
        File dir = new File(savePath);
        System.out.println(appPath);
        System.out.println(savePath);
        System.out.println(dir);
        if (!dir.exists())
            dir.mkdirs();
        File serverFile = new File(dir.getAbsolutePath());
        BufferedOutputStream stream = new BufferedOutputStream(
                new FileOutputStream(serverFile));

0 个答案:

没有答案