上载PDF文件时发生java错误
我有一个Web应用程序,其中包含一个用于上传图像/PDF的表单。然后我将压缩服务器中的图像并存储在数据库中。上载图像时,图像已成功上载。但当我试图上传PDF时,它抛出了FileNotFoundException。以下是例外
java.io.FileNotFoundException: C:\Users\762218\Desktop\w.pdf (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.dcx.service.writeup.dipap.common.ImageResize.calculateFile(Unknown Source)
代码的以下部分会引发异常:
private ByteArrayOutputStream calculateFile(File file) {
long length = file.length();
InputStream in = null;
byte[] array = new byte[(int)length];
try
{
in = new FileInputStream(file);
in.read(array);
System.out.println("innnnnnnnnnnn");
}
catch (Exception e) {
System.out.println("General Exception: "+e);
logger.info("Exception is"+e);
e.printStackTrace();
throw new RuntimeException ("File not found."+e.getMessage());
}
}
注: 1.我已将图像和PDF放在同一位置。所以不可能有任何权限问题。 2.使用HTML5中的文件输入类型上传PDF。因此,文件的路径是正确的
请帮助解决这个问题。我找不到这个错误的任何原因
共 (0) 个答案