本文整理匯總了Java中org.apache.commons.net.ftp.FTPClient.storeFile方法的典型用法代碼示例。如果您正苦於以下問題:Java FTPClient.storeFile方法的具體用法?Java FTPClient.storeFile怎麽用?Java FTPClient.storeFile使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.net.ftp.FTPClient的用法示例。
在下文中一共展示了FTPClient.storeFile方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: uploadFile
點讚 5
import org.apache.commons.net.ftp.FTPClient; //導入方法依賴的package包/類
/**
* 上傳文件至FTP服務器
*
* @author gaoxianglong
*/
public boolean uploadFile(File file) {
boolean result = false;
FTPClient ftpClient = ftpConnManager.getFTPClient();
if (null == ftpClient || !ftpClient.isConnected()) {
return result;
}
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file.getPath()))) {
boolean storeFile = ftpClient.storeFile(file.getName(), in);
if (storeFile) {
result = true;
log.info("file-->" + file.getPath() + "成功上傳至FTP服務器");
}
} catch (Exception e) {
log.error("error", e);
} finally {
disconnect(ftpClient);
}
return result;
}
開發者ID:yunjiweidian,項目名稱:TITAN,代碼行數:25,
示例2: uploadFile
點讚 3
import org.apache.commons.net.ftp.FTPClient; //導入方法依賴的package包/類
/**
* Upload a single file to FTP server with the provided FTP client object.
*
* @param sourceFilePath
* @param targetFilePath
* @param logPrefix
* @throws IOException
*/
protected void uploadFile(final FTPClient ftpClient, final String sourceFilePath, final String targetFilePath,
final String logPrefix) throws IOException {
log.info(String.format(UPLOAD_FILE, logPrefix, sourceFilePath, targetFilePath));
final File sourceFile = new File(sourceFilePath);
try (final InputStream is = new FileInputStream(sourceFile