• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FTPFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getFileInfo

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public EncFSFileInfo getFileInfo(String path) throws IOException {
	try {
		
		String fullPathToList = getParentPath( getAbsolutePath( path));
		if (fullPathToList.endsWith("/")) fullPathToList = fullPathToList.substring(0,fullPathToList.length()-1);
		
		String filenameToSearch = getAbsolutePath( path);
		if (filenameToSearch.endsWith("/")) filenameToSearch=filenameToSearch.substring(0,filenameToSearch.lastIndexOf('/'));
		filenameToSearch=filenameToSearch.substring(filenameToSearch.lastIndexOf("/")+1);
		
		
		
		FTPFile[] remoteFiles = getFtpClient().list(fullPathToList);
	

		
		for (FTPFile file : remoteFiles){
			System.out.println("compare "+file.getName()+" avec "+filenameToSearch);
			if (file.getName().equals(filenameToSearch)) return ftpResource2EncFSFileInfo(getParentPath(path),file);
		}
	} catch (Exception e){
		throw new RuntimeException(e);
	}
	return null;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:26,代码来源:FileProvider2.java


示例17: parse

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public FTPFile[] parse(String[] lines) throws FTPListParseException {
	int size = lines.length;
	FTPFile[] ret = new FTPFile[size];
	for (int i = 0; i < size; i++) {
		Matcher m = PATTERN.matcher(lines[i]);
		if (m.matches()) {
			String month = m.group(1);
			String day = m.group(2);
			String year = m.group(3);
			String hour = m.group(4);
			String minute = m.group(5);
			String ampm = m.group(6);
			String dirOrSize = m.group(7);
			String name = m.group(8);
			ret[i] = new FTPFile();
			ret[i].setName(name);
			if (dirOrSize.equalsIgnoreCase("<DIR>")) {
				ret[i].setType(FTPFile.TYPE_DIRECTORY);
				ret[i].setSize(0);
			} else {
				long fileSize;
				try {
					fileSize = Long.parseLong(dirOrSize);
				} catch (Throwable t) {
					throw new FTPListParseException();
				}
				ret[i].setType(FTPFile.TYPE_FILE);
				ret[i].setSize(fileSize);
			}
			String mdString = month + "/" + day + "/" + year + " " + hour
					+ ":" + minute + " " + ampm;
			Date md;
			try {
				synchronized (DATE_FORMAT) {
					md = DATE_FORMAT.parse(mdString);
				}
			} catch (ParseException e) {
				throw new FTPListParseException();
			}
			ret[i].setModifiedDate(md);
		} else {
			throw new FTPListParseException();
		}
	}
	return ret;
}
 
开发者ID:vitaorganizer,项目名称:vitaorganizer,代码行数:47,代码来源:DOSListParser.java


示例18: parse

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public FTPFile[] parse(String[] lines) throws FTPListParseException {
	int size = lines.length;
	FTPFile[] ret = new FTPFile[size];
	for (int i = 0; i < size; i++) {
		Matcher m = PATTERN.matcher(lines[i]);
		if (m.matches()) {
			String month = m.group(1);
			String day = m.group(2);
			String year = m.group(3);
			String hour = m.group(4);
			String minute = m.group(5);
			String ampm = m.group(6);
			String dirOrSize = m.group(7);
			String name = m.group(8);
			ret[i] = new FTPFile();
			ret[i].setName(name);
			if (dirOrSize.equalsIgnoreCase("<DIR>")) {
				ret[i].setType(FTPFile.TYPE_DIRECTORY);
				ret[i].setSize(0);
			} else {
				long fileSize;
				try {
					fileSize = Long.parseLong(dirOrSize);
				} catch (Throwable t) {
					throw new FTPListParseException();
				}
				ret[i].setType(FTPFile.TYPE_FILE);
				ret[i].setSize(fileSize);
			}
			String mdString = month + "/" + day + "/" + year + " " + hour
					+ ":" + minute + " " + ampm;
			Date md;
			try {
				md = DATE_FORMAT.parse(mdString);
			} catch (ParseException e) {
				throw new FTPListParseException();
			}
			ret[i].setModifiedDate(md);
		} else {
			throw new FTPListParseException();
		}
	}
	return ret;
}
 
开发者ID:jie-meng,项目名称:MFtp,代码行数:45,代码来源:DOSListParser.java


示例19: getmFileList

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public List<FTPFile> getmFileList() {
	return mFileList;
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:4,代码来源:CmdFactory.java


示例20: FtpFileAdapter

import it.sauronsoftware.ftp4j.FTPFile; //导入依赖的package包/类
public FtpFileAdapter(Context context,  List<FTPFile> musicList) 
{
	mContext = context ;
	mInfater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	mFileList = musicList ;
}
 
开发者ID:shrakin,项目名称:FTPClient,代码行数:7,代码来源:FtpFileAdapter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TFCTabs类代码示例发布时间:2022-05-22
下一篇:
Java X509Principal类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap