HttpClient:读入文件://目标

时间:2018-07-26 19:30:26

标签: java apache file import httpclient

因此,我尝试使用HttpClient从公司网络中的远程txt文件读取。没有防火墙或任何阻止我的请求的东西。这是我的代码:

try{
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet("file://hostname/facility_data/Facility_Extract.txt");
    HttpResponse response = client.execute(request);
    HttpEntity entity = response.getEntity();
    BufferedReader in = new BufferedReader((new InputStreamReader(entity.getContent())));
    String input;
    while ((input = in.readLine()) != null) {
        LOG.info(input);
    }
    in.close();
}catch(Exception e){
    LOG.error("Could not access files : "+e.getMessage());
}

我认为这与'file://'协议有关,但是我不确定如何调整以适应该要求。有什么想法吗?

0 个答案:

没有答案