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


Java FileSystemManager.resolveFile方法代码示例

本文整理汇总了Java中org.apache.commons.vfs2.FileSystemManager.resolveFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemManager.resolveFile方法的具体用法?Java FileSystemManager.resolveFile怎么用?Java FileSystemManager.resolveFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.vfs2.FileSystemManager的用法示例。


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

示例1: buildJar

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
private void buildJar(String newJar) throws IOException
{
	ZipOutputStream out = new ZipOutputStream(new FileOutputStream(newJar ));
	FileSystemManager fsManager = VFS.getManager();
	for (String jar : _jar2class.keySet())
	{
		FileObject jarFile;
		if (jar.endsWith(".jar"))
			jarFile = fsManager.resolveFile( "jar:"+jar );
		else
			jarFile = fsManager.resolveFile( jar );
			
			for (String file : _jar2class.get(jar))
			{
				file = file.replaceAll("\\.", "/");
				file += ".class";
				FileObject f = fsManager.resolveFile(jarFile, file);
				if (f.exists())
					addFile(f, file, out);
				else
					System.out.println("file not found "+f);
			}	
			
	}
	out.close();
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:27,代码来源:JarBuilder.java

示例2: main

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		FileSystemManager fileSystemManager = VFS.getManager();
		
		FileObject fileObject;
		String path = "";
        fileObject = fileSystemManager.resolveFile("nfs://10.0.202.122//opt/glog/a.txt");
        if (fileObject == null) {
            throw new IOException("File cannot be resolved: " + path);
        }
        if (!fileObject.exists()) {
            throw new IOException("File does not exist: " + path);
        }
        System.out.println(fileObject.getName().getPath());
        BufferedReader stream = new BufferedReader(new InputStreamReader(fileObject.getContent().getInputStream(), "utf-8"));
       	String line = null;
       	while((line = stream.readLine()) != null) {
       		System.out.println(line);
       	}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:danniss,项目名称:common-vfs2-nfs,代码行数:26,代码来源:Main.java

示例3: UKBenchGroupDataset

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * @param path
 * @param reader
 */
public UKBenchGroupDataset(String path, ObjectReader<IMAGE, FileObject> reader) {
	super(reader);
	this.ukbenchObjects = new HashMap<Integer, UKBenchListDataset<IMAGE>>();
	FileSystemManager manager;
	try {
		manager = VFS.getManager();
		this.base = manager.resolveFile(path);
	} catch (final FileSystemException e) {
		throw new RuntimeException(e);
	}

	for (int i = 0; i < UKBENCH_OBJECTS; i++) {
		this.ukbenchObjects.put(i, new UKBenchListDataset<IMAGE>(path, reader, i));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:UKBenchGroupDataset.java

示例4: getTrainingImages

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Load the training images using the given reader. To load the images as
 * {@link MBFImage}s, you would do the following: <code>
 * CIFAR100Dataset.getTrainingImages(CIFAR100Dataset.MBFIMAGE_READER);
 * </code>
 *
 * @param reader
 *            the reader
 * @param fineLabels
 *            if true, then the fine labels will be used; otherwise the
 *            coarse superclass labels will be used.
 * @return the training image dataset
 * @throws IOException
 */
public static <IMAGE> GroupedDataset<String, ListDataset<IMAGE>, IMAGE> getTrainingImages(BinaryReader<IMAGE> reader,
		boolean fineLabels)
		throws IOException
				{
	final MapBackedDataset<String, ListDataset<IMAGE>, IMAGE> dataset = new MapBackedDataset<String, ListDataset<IMAGE>, IMAGE>();

	final FileSystemManager fsManager = VFS.getManager();
	final FileObject base = fsManager.resolveFile(downloadAndGetPath());

	final List<String> classList = loadClasses(dataset, base, fineLabels);

	DataInputStream is = null;
	try {
		is = new DataInputStream(base.resolveFile(TRAINING_FILE).getContent().getInputStream());

		loadData(is, dataset, classList, reader, 50000, fineLabels);
	} finally {
		IOUtils.closeQuietly(is);
	}

	return dataset;
				}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:37,代码来源:CIFAR100Dataset.java

示例5: getTestImages

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Load the test images using the given reader. To load the images as
 * {@link MBFImage}s, you would do the following: <code>
 * CIFAR100Dataset.getTestImages(CIFAR100Dataset.MBFIMAGE_READER);
 * </code>
 *
 * @param reader
 *            the reader
 * @param fineLabels
 *            if true, then the fine labels will be used; otherwise the
 *            coarse superclass labels will be used.
 * @return the test image dataset
 * @throws IOException
 */
public static <IMAGE> GroupedDataset<String, ListDataset<IMAGE>, IMAGE> getTestImages(BinaryReader<IMAGE> reader,
		boolean fineLabels)
				throws IOException
				{
	final MapBackedDataset<String, ListDataset<IMAGE>, IMAGE> dataset = new MapBackedDataset<String, ListDataset<IMAGE>, IMAGE>();

	final FileSystemManager fsManager = VFS.getManager();
	final FileObject base = fsManager.resolveFile(downloadAndGetPath());

	final List<String> classList = loadClasses(dataset, base, fineLabels);

	DataInputStream is = null;
	try {
		is = new DataInputStream(base.resolveFile(TEST_FILE).getContent().getInputStream());
		loadData(is, dataset, classList, reader, 10000, fineLabels);
	} finally {
		IOUtils.closeQuietly(is);
	}

	return dataset;
				}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:CIFAR100Dataset.java

示例6: Record

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
protected Record(FileObject image) throws FileSystemException, IOException {
	final FileSystemManager fsManager = VFS.getManager();
	final FileObject imagesBase = fsManager.resolveFile(downloadAndGetImagePath());
	final FileObject annotationsBase = fsManager.resolveFile(downloadAndGetAnnotationPath());

	// get the id
	id = imagesBase.getName().getRelativeName(image.getName());

	// the class
	objectClass = image.getParent().getName().getBaseName();

	// find the annotation file
	final String annotationFileName = id.replace("image_", "annotation_").replace(".jpg", ".mat");
	final FileObject annotationFile = annotationsBase.resolveFile(annotationFileName);
	parseAnnotations(annotationFile);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:Caltech101.java

示例7: getTrainingImages

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Load the training images using the given reader. To load the images as
 * {@link MBFImage}s, you would do the following: <code>
 * CIFAR10Dataset.getTrainingImages(CIFAR10Dataset.MBFIMAGE_READER);
 * </code>
 *
 * @param reader
 *            the reader
 * @return the training image dataset
 * @throws IOException
 */
public static <IMAGE> GroupedDataset<String, ListDataset<IMAGE>, IMAGE> getTrainingImages(BinaryReader<IMAGE> reader)
		throws IOException
{
	final MapBackedDataset<String, ListDataset<IMAGE>, IMAGE> dataset = new MapBackedDataset<String, ListDataset<IMAGE>, IMAGE>();

	final FileSystemManager fsManager = VFS.getManager();
	final FileObject base = fsManager.resolveFile(downloadAndGetPath());

	final List<String> classList = loadClasses(dataset, base);

	for (final String t : TRAINING_FILES) {
		DataInputStream is = null;
		try {
			is = new DataInputStream(base.resolveFile(t).getContent().getInputStream());

			loadData(is, dataset, classList, reader);
		} finally {
			IOUtils.closeQuietly(is);
		}
	}

	return dataset;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:CIFAR10Dataset.java

示例8: getTestImages

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Load the test images using the given reader. To load the images as
 * {@link MBFImage}s, you would do the following: <code>
 * CIFAR10Dataset.getTestImages(CIFAR10Dataset.MBFIMAGE_READER);
 * </code>
 *
 * @param reader
 *            the reader
 * @return the test image dataset
 * @throws IOException
 */
public static <IMAGE> GroupedDataset<String, ListDataset<IMAGE>, IMAGE> getTestImages(BinaryReader<IMAGE> reader)
		throws IOException
{
	final MapBackedDataset<String, ListDataset<IMAGE>, IMAGE> dataset = new MapBackedDataset<String, ListDataset<IMAGE>, IMAGE>();

	final FileSystemManager fsManager = VFS.getManager();
	final FileObject base = fsManager.resolveFile(downloadAndGetPath());

	final List<String> classList = loadClasses(dataset, base);

	DataInputStream is = null;
	try {
		is = new DataInputStream(base.resolveFile(TEST_FILE).getContent().getInputStream());
		loadData(is, dataset, classList, reader);
	} finally {
		IOUtils.closeQuietly(is);
	}

	return dataset;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:32,代码来源:CIFAR10Dataset.java

示例9: testVfs

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
@Test
public void testVfs() throws Exception {
  
  ((DefaultFileSystemManager)VFS.getManager()).addProvider("mtm", new MetadataToMondrianVfs());
  
  FileSystemManager fsManager = VFS.getManager();
  FileObject fobj = fsManager.resolveFile("mtm:src/test/resources/example_olap.xmi");
  StringBuilder buf = new StringBuilder(1000);
  InputStream in = fobj.getContent().getInputStream();
  int n;
  while ((n = in.read()) != -1) {
      buf.append((char) n);
  }
  in.close();
  String results = buf.toString();
  assertTrue(results.indexOf("<Cube name=\"customer2 Table\">") >= 0);
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:18,代码来源:MetadataToMondrianVfsTest.java

示例10: fillTableData

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
private void fillTableData(String selectedDir, Table table, FileSystemManager fsManager, FileSystemOptions opts, String filterVal)
		throws IOException {
	table.removeAllItems();

	FileObject fileObject = fsManager.resolveFile(selectedDir, opts);
	FileObject[] files = fileObject.getChildren();
	for (FileObject file : files) {

		if (filterVal == null) {
			addTableItem(table, file);
		} else {
			String regex = filterVal.replace("?", ".?").replace("*", ".*?");
			String name = getDisplayPath(file.getName().toString());
			if (name.matches(regex))
				addTableItem(table, file);
		}

	}
}
 
开发者ID:Union-Investment,项目名称:vfs2-file-explorer,代码行数:20,代码来源:TableView.java

示例11: start

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Starts watching the file system for changes to trigger a bake.
 *
 * @param res Commandline options
 * @param config Configuration settings
 */
public void start(final LaunchOptions res, CompositeConfiguration config) {
    try {
        FileSystemManager fsMan = VFS.getManager();
        FileObject listenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.CONTENT_FOLDER));
        FileObject templateListenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.TEMPLATE_FOLDER));
        FileObject assetPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.ASSET_FOLDER));


        System.out.println("Watching for (content, template, asset) changes in [" + res.getSource() + "]");
        DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(res, config));
        monitor.setRecursive(true);
        monitor.addFile(listenPath);
        monitor.addFile(templateListenPath);
        monitor.addFile(assetPath);
        monitor.start();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:26,代码来源:BakeWatcher.java

示例12: watchDir

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
@Override
public void watchDir(File file) throws IOException {

	FileSystemManager fileSystemManager = VFS.getManager();
	FileObject dirToWatchFO = null;
	dirToWatchFO = fileSystemManager.resolveFile(file.getAbsolutePath());

	//IFileListenerService fileListener = this.beanService.getBean(ApacheDefaultFileListener.class);
	DefaultFileMonitor fileMonitor = this.beanService.getBean(DefaultFileMonitor.class);

	fileMonitor.setRecursive(true);
	fileMonitor.addFile(dirToWatchFO);
	fileMonitor.start();
	
	this.fileMonitors.add(fileMonitor);
}
 
开发者ID:vauvenal5,项目名称:pieShare,代码行数:17,代码来源:ApacheFileWatcherService.java

示例13: start

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Starts watching the file system for changes to trigger a bake.
 *
 * @param res Commandline options
 * @param config Configuration settings
 */
public void start(final LaunchOptions res, CompositeConfiguration config) {
    try {
        FileSystemManager fsMan = VFS.getManager();
        FileObject listenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.CONTENT_FOLDER));

        System.out.println("Watching for changes in [" + res.getSource() + "]");
        DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(res, config));
        monitor.setRecursive(true);
        monitor.addFile(listenPath);
        monitor.start();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:21,代码来源:BakeWatcher.java

示例14: createStorageProvider

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
@Override
public StorageProvider createStorageProvider(Map<String, ? extends Object> properties) {
	String ftpUrl = normalize(properties);
	
	try {
		FileSystemManager fsManager = VFS.getManager();
		FileSystemOptions opts = new FileSystemOptions();
		FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false);
		FileObject fileObject = fsManager.resolveFile(ftpUrl, opts);
		
		boolean createDirectory = getBoolean(properties, FtpStorage.CREATE_DIRECTORY_PROPERTY, false);
		
		fsManager.getFilesCache().clear(fileObject.getFileSystem());
		if (!fileObject.exists()) {
			if (createDirectory) {
				fileObject.createFolder();
			} else {
				throw new StorageException("The given base path does not resolve to an existing directory: " + ftpUrl);
			}
		}
		
		if (fileObject.getType() != FileType.FOLDER) {
			throw new StorageException("The given base path does not resolve to an existing directory: " + ftpUrl);
		}
		
		// TODO: Maybe try to create a little test object so we can self check if writing is allowed
		boolean supportsWriting = true;
		
		return new FtpStorageProvider(fileObject, supportsWriting);
	} catch (FileSystemException ex) {
		throw new StorageException("Could not connect to the ftp storage at: " + ftpUrl, ex);
	}
}
 
开发者ID:Blazebit,项目名称:blaze-storage,代码行数:34,代码来源:FtpStorageProviderFactory.java

示例15: resolve

import org.apache.commons.vfs2.FileSystemManager; //导入方法依赖的package包/类
/**
 * Resolve a set of URIs into FileObject objects.
 * This is not recursive. The URIs can refer directly to a file or directory or an optional regex at the end.
 * (NOTE: This is NOT a glob).
 * @param vfs The file system manager to use to resolve URIs
 * @param uris comma separated URIs and URI + globs
 * @return
 * @throws FileSystemException
 */
static FileObject[] resolve(FileSystemManager vfs, String uris) throws FileSystemException {
  if (uris == null) {
    return new FileObject[0];
  }

  ArrayList<FileObject> classpath = new ArrayList<>();
  for (String path : uris.split(",")) {
    path = path.trim();
    if (path.equals("")) {
      continue;
    }
    FileObject fo = vfs.resolveFile(path);
    switch (fo.getType()) {
      case FILE:
      case FOLDER:
        classpath.add(fo);
        break;
      case IMAGINARY:
        // assume its a pattern
        String pattern = fo.getName().getBaseName();
        if (fo.getParent() != null && fo.getParent().getType() == FileType.FOLDER) {
          FileObject[] children = fo.getParent().getChildren();
          for (FileObject child : children) {
            if (child.getType() == FileType.FILE && child.getName().getBaseName().matches(pattern)) {
              classpath.add(child);
            }
          }
        } else {
          LOG.warn("ignoring classpath entry {}", fo);
        }
        break;
      default:
        LOG.warn("ignoring classpath entry {}", fo);
        break;
    }
  }
  return classpath.toArray(new FileObject[classpath.size()]);
}
 
开发者ID:apache,项目名称:metron,代码行数:48,代码来源:VFSClassloaderUtil.java


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