本文整理匯總了Java中org.apache.commons.net.ftp.FTPClient.appendFileStream方法的典型用法代碼示例。如果您正苦於以下問題:Java FTPClient.appendFileStream方法的具體用法?Java FTPClient.appendFileStream怎麽用?Java FTPClient.appendFileStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.net.ftp.FTPClient
的用法示例。
在下文中一共展示了FTPClient.appendFileStream方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: uploadFile
import org.apache.commons.net.ftp.FTPClient; //導入方法依賴的package包/類
/**
* �ϴ��ļ���������,���ϴ��Ͷϵ�����
* @param remoteFile Զ���ļ��������ϴ�֮ǰ�Ѿ�������������Ŀ¼���˸ı�
* @param localFile �����ļ� File���������·��
* @param processStep ��Ҫ��ʾ�Ĵ�����Ȳ���ֵ
* @param ftpClient FTPClient ����
* @return
* @throws IOException
*/
public UploadStatus uploadFile(String remoteFile,File localFile,FTPClient ftpClient,long remoteSize) throws IOException{
UploadStatus status;
//��ʾ���ȵ��ϴ�
long step = localFile.length() / 100;
long process = 0;
long localreadbytes = 0L;
RandomAccessFile raf = new RandomAccessFile(localFile,"r");
OutputStream out = ftpClient.appendFileStream(new String(remoteFile.getBytes("GBK"),"iso-8859-1"));
//�ϵ�����
if(remoteSize>0){
ftpClient.setRestartOffset(remoteSize);
process = remoteSize /step;
raf.seek(remoteSize);
localreadbytes = remoteSize;
}
byte[] bytes = new byte[1024];
int c;
while((c = raf.read(bytes))!= -1){
out.write(bytes,0,c);
localreadbytes+=c;
if(localreadbytes / step != process){
process = localreadbytes / step;
System.out.println("�ϴ�����:" + process);
//TODO �㱨�ϴ�״̬
}
}
out.flush();
raf.close();
out.close();
boolean result =ftpClient.completePendingCommand();
if(remoteSize > 0){
status = result?UploadStatus.Upload_From_Break_Success:UploadStatus.Upload_From_Break_Failed;
}else {
status = result?UploadStatus.Upload_New_File_Success:UploadStatus.Upload_New_File_Failed;
}
return status;
}