下载服务器上的文件—通过url

【下载服务器上的文件—通过url】String fileHome = this.getServlet().getServletContext().getRealPath("/");

InputStream is;

FileOutputStream fileOut = new FileOutputStream(fileHome + "upload/receive/" + md.getId()+1 + ".zip");

URL url = new URL(md.getFromIp().replace("receive/onlineExport.do", "upload/receive/" + md.getId() + ".zip"));

URLConnection c = url.openConnection(); // *

c.connect();

is = c.getInputStream();

int data;

while ((data = https://www.it610.com/article/is.read()) != -1) {

fileOut.write(data);

}

is.close();

fileOut.close();

    推荐阅读