当前位置: 首页>>代码示例>>Java>>正文


Java FTPFile类代码示例

本文整理汇总了Java中it.sauronsoftware.ftp4j.FTPFile的典型用法代码示例。如果您正苦于以下问题:Java FTPFile类的具体用法?Java FTPFile怎么用?Java FTPFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FTPFile类属于it.sauronsoftware.ftp4j包,在下文中一共展示了FTPFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fsList

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Override
public List<EncFSFileInfo> fsList(String path) throws IOException {
	List<EncFSFileInfo> list = new ArrayList<EncFSFileInfo>();
	
	try {
		if (path.endsWith("/")) path = path.substring(0,path.length()-1);
		
		//i dont know why: but with listFile encFS provide the absolute url
		//I DO NOT have to concatenate with rootpath....
		
		FTPFile[] remoteFiles = getFtpClient().list(getAbsolutePath(path));
	
		for (FTPFile childEnt : remoteFiles) {
			if (".".equals(childEnt.getName()) || "..".equals(childEnt.getName())) continue;
			list.add(ftpResource2EncFSFileInfo(path,childEnt));
		}
		
		return list;
	} catch (Exception e){
		throw new IOException(e);
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:23,代码来源:FileProvider2.java

示例2: retryableFileList

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Retryable(backoff = @Backoff(2000L))
private List<RemoteFile> retryableFileList(GameServer server, String dir, Predicate<RemoteFile> filter) throws IOException {
    log.debug("Preparing to get file list from {} ({}) on directory {}", server.getShortName(), server.getAddress(), dir);
    Optional<FtpClient> o = establishFtpConnection(server);
    if (o.isPresent()) {
        FtpClient client = o.get();
        List<FTPFile> files = client.list(dir);
        if (files.isEmpty()) {
            client.disconnect();
            throw new IOException("No files found");
        }
        // map FTPFiles to RemoteFiles
        List<RemoteFile> remotes = files.stream()
            .map(f -> mapToRemoteFile(f, server, dir))
            .filter(filter)
            .map(this::updateIfNeeded)
            .sorted()
            .collect(Collectors.toList());
        remoteFileRepository.save(remotes);
        client.disconnect();
        return remotes;
    } else {
        throw new IOException("Could not establish connection");
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:26,代码来源:SyncGroupService.java

示例3: listFiles

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
/**
 * Lists the files present at the specified path.
 * @param path The specified path.
 * @return The list of files.
 */
public List<FileEntity> listFiles(FtpServer server, String path) throws FTPException, IOException, FTPIllegalReplyException, FTPAbortedException, FTPDataTransferException, FTPListParseException {
    FTPClient client = this.getConnection(server);

    if(path != null && !path.equals("/")) {
        client.changeDirectory(path);
    }

    FTPFile[] list = client.list();

    List<FileEntity> results = new ArrayList<FileEntity>();

    if(list != null) {
        for (FTPFile file : list) {
            if(!file.getName().equals("..")) {
                results.add(this.ftpFileToEntity(file, path));
            }
        }
    }

    Collections.sort(results);

    return results;
}
 
开发者ID:Paul-DS,项目名称:SimpleFTP,代码行数:29,代码来源:FtpRepository.java

示例4: findServerLatestBuild

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
private FTPFile findServerLatestBuild() throws FtpToolException {
	monitor.subTask("Finding the latest build source folder on Ftp server ...");
	ftpTool = new FtpTool(ftpInfo, TemplateVariable.getInstance().getValue(TemplateVariable.HMM_DIR));
	List<FTPFile> files = null;
	ftpTool.connect();
	ftpTool.login();
	files = ftpTool.getFileList();
	for (FTPFile ftpFile : files) {
		if(ftpFile.getType() == FTPFile.TYPE_DIRECTORY) {
			String str = ftpFile.getName();
			if(str.matches("^\\d{4}-[0-1]\\d-[0-3]\\d_[0-2]\\d_[0-6]\\d_[0-6]\\d"))
				if ( (latestBuildFolder == null) || (latestBuildFolder.getName().compareTo(str) < 0) )
					latestBuildFolder = ftpFile;
		}
	}
	return latestBuildFolder;
}
 
开发者ID:AlexWengh,项目名称:HMM,代码行数:18,代码来源:ScheduledBuildClientJob.java

示例5: run

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Override
public void run() {
	// TODO Auto-generated method stub
	try {
		mCurrentPWD = mFTPClient.currentDirectory();
		FTPFile[] ftpFiles = mFTPClient.list();
		Log.v(TAG, " Request Size  : " + ftpFiles.length);
		synchronized (mLock) {
			mFileList.clear();
			mFileList.addAll(Arrays.asList(ftpFiles));
		}
		mHandler.sendEmptyMessage(GlobalConstant.MSG_CMD_LIST_OK);

	} catch (Exception ex) {
		mHandler.sendEmptyMessage(GlobalConstant.MSG_CMD_LIST_FAILED);
		ex.printStackTrace();
	}
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:19,代码来源:CmdFactory.java

示例6: ftpResource2EncFSFileInfo

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
private EncFSFileInfo ftpResource2EncFSFileInfo(String parentPath , FTPFile file){
	//String distantPath = parentPath;//+"/"+file.getName();
	String relativePath = parentPath;//getRelativePathFromAbsolutePath(distantPath);
	if ("".equals(relativePath)) relativePath="/";
	System.out.println("celle ci retourne:"+relativePath+" => "+file.getName());
	EncFSFileInfo effi = new EncFSFileInfo(file.getName(),relativePath,file.getType()==1?true:false,file.getModifiedDate().getTime(),file.getSize(),true,true,true);
	return effi;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:9,代码来源:FileProvider2.java

示例7: mapToRemoteFile

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
private RemoteFile mapToRemoteFile(FTPFile file, GameServer server, String dir) {
    RemoteFile remote = new RemoteFile();
    remote.setFilename(file.getName());
    remote.setFolder(dir);
    remote.setServer(server.getShortName());
    remote.setSize(file.getSize());
    Date modifiedDate = file.getModifiedDate();
    if (modifiedDate != null) {
        // convert keeping the time but changing the time-zone
        remote.setModified(correctOffsetSameZone(modifiedDate));
    }
    return remote;
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:14,代码来源:SyncGroupService.java

示例8: ftpFileToEntity

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
/**
 * Convert a FTP file to a file entity.
 * @param file The FTP file to convert.
 * @param currentPath The path where the file has been found.
 * @return The converted file entity.
 */
private FileEntity ftpFileToEntity(FTPFile file, String currentPath)
{
    FileEntity entity = new FileEntity();
    entity.setPath(currentPath.endsWith("/")
            ? currentPath + file.getName()
            : currentPath + "/" + file.getName());

    entity.setName(file.getName());
    entity.setSize(file.getSize());
    entity.setIsDirectory(file.getType() == FTPFile.TYPE_DIRECTORY);
    return entity;
}
 
开发者ID:Paul-DS,项目名称:SimpleFTP,代码行数:19,代码来源:FtpRepository.java

示例9: main

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {
	String[] test = { "+i8388621.29609,m824255902,/,\tdev",
			"+i8388621.44468,m839956783,r,s10376,\tRFCEPLF" };
	EPLFListParser parser = new EPLFListParser();
	FTPFile[] f = parser.parse(test);
	for (int i = 0; i < f.length; i++) {
		System.out.println(f[i]);
	}
}
 
开发者ID:vitaorganizer,项目名称:vitaorganizer,代码行数:10,代码来源:EPLFListParser.java

示例10: parse

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public FTPFile[] parse(String[] lines) throws FTPListParseException {
	ArrayList list = new ArrayList();
	for (int i = 0; i < lines.length; i++) {
		FTPFile file = parseLine(lines[i]);
		if (file != null) {
			list.add(file);
		}
	}
	int size = list.size();
	FTPFile[] ret = new FTPFile[size];
	for (int i = 0; i < size; i++) {
		ret[i] = (FTPFile) list.get(i);
	}
	return ret;
}
 
开发者ID:vitaorganizer,项目名称:vitaorganizer,代码行数:16,代码来源:MLSDListParser.java

示例11: retrieveDir

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
/**
 * Speichert alles im Remote-Directory im local-Verzeichnis.
 */
public static void retrieveDir (String remote, File local, FtpConnection con)
		throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
		FTPListParseException
{
	boolean conWasNull = con == null;
	if (conWasNull)
		con = cons.getClient();
	FTPClient client = con.getFtpClient();
	
	try
	{
		String cwd = client.currentDirectory();
		client.changeDirectory(remote);
		local.mkdirs();
		for (FTPFile f : client.list())
		{
			if (f.getType() == FTPFile.TYPE_FILE)
				retrieveFile(f.getName(), new File(local, f.getName()), con);
			else if (f.getType() == FTPFile.TYPE_DIRECTORY)
				retrieveDir(f.getName(), new File(local, f.getName()), con);
		}
		client.changeDirectory(cwd);
	}
	finally
	{
		if (conWasNull)
			con.setBusy(false);
	}
}
 
开发者ID:Turnierserver,项目名称:Turnierserver,代码行数:33,代码来源:DatastoreFtpClient.java

示例12: getView

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Override
public View getView(int position, View convertview, ViewGroup viewGroup) {
	
	View view = null;
	ViewHolder holder = null;
	/*if (convertview == null || convertview.getTag() == null) 
	{
		view = mInfater.inflate(R.layout.ftp_file_item, null);
		holder = new ViewHolder(view);
		view.setTag(holder);
	} 
	else
	{
		view = convertview ;
		holder = (ViewHolder) convertview.getTag() ;
	}*/
	
	view = mInfater.inflate(R.layout.ftp_file_item, null);
	holder = new ViewHolder(view);
	view.setTag(holder);
	
	FTPFile ftpFile =  getItem(position);
	
	holder.appIcon.setImageResource(FileTypeToImageUtil.changeFileTypeToDrawable(ftpFile));
	holder.tvName.setText(ftpFile.getName());
	holder.tvAuthor.setText(Formatter.formatFileSize(mContext, ftpFile.getSize()));
	holder.tvDuration.setText(makeSimpleDateStringFromLong(ftpFile.getModifiedDate().getTime()));
	return view;
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:30,代码来源:FtpFileAdapter.java

示例13: changeFileTypeToDrawable

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public static int changeFileTypeToDrawable(FTPFile mFile){
	if (mFile.getType() == FTPFile.TYPE_DIRECTORY) {
		return R.drawable.dir;
	}else{
		return changeFileTypeToDrawable(mFile.getName());
	}
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:8,代码来源:FileTypeToImageUtil.java

示例14: list

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Override
public FTPFile[] list() throws IllegalStateException, IOException,
		FTPIllegalReplyException, FTPException, FTPDataTransferException,
		FTPAbortedException, FTPListParseException {
	// TODO Auto-generated method stub
	return super.list();
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:8,代码来源:FtpClientProxy.java

示例15: onContextItemSelected

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
	if (mSelectedPosistion < 0 || mFileList.size() < 0) {
		return false;
	}
	AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item
			.getMenuInfo();
	switch (item.getItemId()) {
	case MENU_OPTIONS_DOWNLOAD:
		if (mFileList.get(mSelectedPosistion).getType() == FTPFile.TYPE_FILE) {
			showDialog(DIALOG_LOAD);
			new CmdDownLoad(mFTPClient, mProcessBarHandler, mFileList.get(mSelectedPosistion)).execute();
		} else {
			toast("只能上传文件");
		}
		break;
	case MENU_OPTIONS_RENAME:
		showDialog(DIALOG_RENAME);
		break;
	case MENU_OPTIONS_DELETE:
		mExecutorServiceProxy.executeDELERequest(
				mFileList.get(mSelectedPosistion).getName(),
				mFileList.get(mSelectedPosistion).getType() == FTPFile.TYPE_DIRECTORY);

		break;
	default:
		return super.onContextItemSelected(item);
	}
	return true;
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:31,代码来源:FtpMainActivity.java


注:本文中的it.sauronsoftware.ftp4j.FTPFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。