| File was renamed from src/main/java/org/springblade/modules/information/controller/FtpUtil.java |
| | |
| | | package org.springblade.modules.information.controller; |
| | | |
| | | import java.io.BufferedOutputStream; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.SocketException; |
| | | package org.springblade.common.utils; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.commons.net.ftp.FTP; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | | import org.apache.commons.net.ftp.FTPReply; |
| | | |
| | | import java.io.*; |
| | | import java.net.SocketException; |
| | | |
| | | /** |
| | | * ftp工具类 |
| | |
| | | InputStream retrieveFileStream = ftpClient.retrieveFileStream(fileNameTemp); |
| | | |
| | | // 第一种方式下载文件(推荐) |
| | | /* File localFile = new File(localPath + File.separatorChar + fileName); |
| | | OutputStream os = new FileOutputStream(localFile); |
| | | ftpClient.retrieveFile(fileName, os); os.close();*/ |
| | | //File localFile = new File(localPath + File.separatorChar + fileName); |
| | | //OutputStream os = new FileOutputStream(localFile); |
| | | //ftpClient.retrieveFile(fileName, os); os.close(); |
| | | |
| | | |
| | | // 第二种方式下载:将输入流转成字节,再生成文件,这种方式方便将字节数组直接返回给前台jsp页面 |