看看下面的方法,也许对你有帮助:
@echo off
rem 指定FTP用户名
set ftpUser=FTPUSERYGL
rem 指定FTP密码
set ftpPass=FTPUSER
rem 指定FTP服务器地址
set ftpIP=10.16.12.101
rem 指定待下载的文件位于FTP服务器的哪个目录
set ftpFolder=/MBX-YGL-IN/UE0620/MBX-YGL-FTP/
rem 指定从FTP下载下来的文件存放到本机哪个目录
set LocalFolder=D:/Download
set ftpFile=%temp%/TempFTP.txt
>"%ftpFile%" (
echo,%ftpUser%
echo,%ftpPass%
echo cd "%ftpFolder%"
echo lcd "%LocalFolder%"
echo bin
echo mget *.*
echo bye
)
start ftp -v -i -s:"%ftpFile%" %ftpIP%
在jsp/servlet中断点/多线程下载文件
<%@ page import="java.io.File" %><%@ page import="java.io.IOException" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.RandomAccessFile" %>
<%!
public void downloadFile(HttpServletRequest request, HttpServletResponse response, File file) throws IOException {
RandomAccessFile raf = new RandomAccessFile(file, "r")
java.io.FileInputStream fis = new java.io.FileInputStream(raf.getFD())
response.setHeader("Server", "www.trydone.com")
response.setHeader("Accept-Ranges", "bytes")
long pos = 0
long len
len = raf.length()
if (request.getHeader("Range") != null) {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT)
pos = Long.parseLong(request.getHeader("Range")
.replaceAll("bytes=", "")
.replaceAll("-", "")
)
}
response.setHeader("Content-Length", Long.toString(len - pos))
if (pos != 0) {
response.setHeader("Content-Range", new StringBuffer()
.append("bytes ")
.append(pos)
.append("-")
.append(Long.toString(len - 1))
.append("/")
.append(len)
.toString()
)
}
response.setContentType("application/octet-stream")
response.setHeader("Content-Disposition", new StringBuffer()
.append("attachmentfilename=\"")
.append(file.getName())
.append("\"").toString())
raf.seek(pos)
byte[] b = new byte[2048]
int i
OutputStream outs = response.getOutputStream()
while ((i = raf.read(b)) != -1) {
outs.write(b, 0, i)
}
raf.close()
fis.close()
}
%>
<%
String filePath = request.getParameter("file")
filePath = application.getRealPath(filePath)
File file = new File(filePath)
downloadFile(request, response, file)
%>
直接将资源放在一个服务器上让其他机器下载即可1、比较好的方法是搭建一个文本服务器比如mginx之类的,然后将资源当道里面,直接下载就好了,这样速度比较快
2、当然也是可以使用用文件共享ftp之类的方法进行文件的共享下载也是非常的不错的
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)