从远程服务器位置下载文件



嗨,我必须从我们的svn服务器位置下载一个文件。文件url如下-https://abc.xyz.com/svn/MyProject/trunk/documents/abc.docx下载。请帮助如何下载。提前感谢

Simple:打开连接并将inputStream复制到目标文件outputStream:

public void downloadFile(String location, File destinationFile) throws IOException
{
    try (FileOutputStream fos = new FileOutputStream( destinationFile )){
        URL url = new URL(location);
        URLConnection connection = url.openConnection();
        IOUtils.copy( connection.getInputStream(),  fos);
    } 
}

最新更新