Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
原因:java.io.IOException:File/tmp/lp/lp.2015.4.28.10.29.40.zip不是文件或不';不存在_Java_File - Fatal编程技术网

原因:java.io.IOException:File/tmp/lp/lp.2015.4.28.10.29.40.zip不是文件或不';不存在

原因:java.io.IOException:File/tmp/lp/lp.2015.4.28.10.29.40.zip不是文件或不';不存在,java,file,Java,File,这就是我的代码的外观 protected Response uploadFile(final File file) throws HttpUploadException { System.out.println("Uploader uploading " + file.getAbsolutePath()); System.out.println("Uploader file exists " + file.exists()); final String endPoint

这就是我的代码的外观

protected Response uploadFile(final File file) throws HttpUploadException {
    System.out.println("Uploader uploading " + file.getAbsolutePath());
    System.out.println("Uploader file exists " + file.exists());
    final String endPoint = endPoint.getAppURL() + "/" + uri;
    final Response response;
    try {
      response =
          remoteResource.uploadFileAndGetResponse(endPoint, file.getAbsoluteFile(), "application/octet-stream",
                                                         Collections.<String, String>emptyMap());

    } catch (final Exception e) {
      throw new HttpUploadException("Failed to upload data to " + endPoint, e);
    }
}
然后我认为例外是

com.pro.logs.client.HttpUploadException: Failed to upload data to https://mystat.pro.net:443/importer
    at com.shn.logs.common.Uploader.uploadFile(Uploader.java:54)
    at com.pro.logs.controller.report.LPDiagnosticReportUploader.upload(LPDiagnosticReportUploader.java:12)
    at com.pro.logs.controller.report.ReportSender$ReportSenderRunnable.executeTasks(ReportSender.java:109)
    at com.pro.logs.controller.report.ReportSender$ReportSenderRunnable.run(ReportSender.java:92)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: File /tmp/lp/LP.2015.4.28.10.29.40.zip is not a file or doesn't exist
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.construct(NettyAsyncHttpProvider.java:891)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.buildRequest(NettyAsyncHttpProvider.java:657)
    at com.ning.http.client.providers.netty.NettyConnectListener$Builder.build(NettyConnectListener.java:145)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1071)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:940)
    at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:499)
    at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.execute(AsyncHttpClient.java:229)
    at com.shn.util.RemoteResourceManager.uploadFileAndGetResponse(RemoteResourceManager.java:137)
    at com.pro.logs.common.Uploader.uploadFile(Uploader.java:50)
    ... 6 more

当文件已经存在时,有什么问题吗?

我想这是因为
ZIP
文件不是
文件

System.out.println("Uploader file isFile? " + file.isFile());
我明白了

我现在有一个不同的问题

isFile()
仅当文件
不是目录并且满足其他依赖于系统的条件时才会返回true
。您可以尝试检查是否指向软链接或其他内容。
System.out.println("Uploader file isFile? " + file.isFile());
Uploader file isFile? false