java下载远程文件到本地
java下载远程文件到本地(转载:https://www.geek-share.com/detail/2573027780.html)
/**
* 下载远程文件并保存到本地
* @param remoteFilePath 远程文件路径
* @param localFilePath 本地文件路径(带文件名)
*/
public void downloadFile(String remoteFilePath, String localFilePath)
{
URL urlfile = null;
HttpURLConnection httpUrl = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
File f = new File(localFilePath);
try
{
urlfile = new URL(remoteFilePath);
httpUrl = (HttpURLConnection)urlfile.openConnection();
httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(f));
int len = 2048;
byte[] b = new byte[len];
while ((len = bis.read(b)) != -1)
{
bos.write(b, 0, len);
}
bos.flush();
bis.close();
httpUrl.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
bis.close();
bos.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
- java 远程从FTP服务器下载文件到本地
- java下载远程http地址的图片文件到本地-自动处理图片是否经过服务器gzip压缩的问题
- java 远程从FTP服务器下载文件到本地
- java下载远程文件到本地
- 工具类—Java下载远程文件到本地
- java下载远程http地址的图片文件到本地-自动处理图片是否经过服务器gzip压缩的问题
- java 下载远程电脑文件到本地电脑
- java下载远程FTP文件至本地
- java下载远程文件到本地
- java 远程从FTP服务器下载文件到本地
- IO Foundation 12 - 下载远程文件到本地
- php带密码功能并下载远程文件保存本地指定目录 修改加强版
- java中如何获取远程计算机post提交的数据并把这些数据写入本地的txt文件中
- python urllib从远程服务器下载文件到本地
- C#下载远程服务器文件到本地服务器
- JAVA远程下载文件 总结 思路~~Myself
- a_p_p_l_e_下载远程文件到本地并执行 例子
- ASP.NET获取远程网页下载到本地文件
- Java 通过SMB服务远程下载文件及zip包中的文件
- Java实现跨域文件下载(下载远程文件)