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


Java FileSystemManager类代码示例

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


FileSystemManager类属于org.apache.commons.vfs2包,在下文中一共展示了FileSystemManager类的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: getFileSystemManager

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
/**
 * Returns the global filesystem manager
 *
 * @return the global filesystem manager
 */
public static FileSystemManager getFileSystemManager() {
  aLock.readLock().lock();

  try {
    if (fileSystemManager == null) {
      try {
        StandardFileSystemManager fm = new StandardFileSystemManager();
        fm.setCacheStrategy(CacheStrategy.MANUAL);
        fm.init();
        LOGGER.info("Supported schemes: {} ", Joiner.on(", ").join(fm.getSchemes()));
        fileSystemManager = fm;
      } catch (Exception exc) {
        throw new RuntimeException(exc);
      }
    }

    return fileSystemManager;
  } finally {
    aLock.readLock().unlock();
  }
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:27,代码来源:VFSUtils.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: addFileObjects

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
/**
 * Appends the specified FileObjects to the list of FileObjects to search
 * for classes and resources.
 *
 * @param manager The FileSystemManager.
 * @param files the FileObjects to append to the search path.
 * @throws FileSystemException if an error occurs.
 */
private void addFileObjects(final FileSystemManager manager,
                            final FileObject[] files) throws FileSystemException
{
    for (int i = 0; i < files.length; i++)
    {
        FileObject file = files[i];
        if (!file.exists())
        {
            // Does not exist - skip
            continue;
        }

        // TODO - use federation instead
        if (manager.canCreateFileSystem(file))
        {
            // Use contents of the file
            file = manager.createFileSystem(file);
        }

        resources.add(file);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:31,代码来源:VFSClassLoader.java

示例12: testFiles

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
private static void testFiles(FileSystemManager mgr) throws FileSystemException
{
    for (int i = 0; i < 10; i++)
    {
        // warmup jvm
        mgr.resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:[email protected]/vfsusr/many/path/elements/with%25esc/any%25where/to/file.txt");
    }

    long start = System.currentTimeMillis();
    for (int i = 0; i < NUOF_RESOLVES; i++)
    {
        mgr.resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:[email protected]/vfsusr/many/path/elements/with%25esc/any%25where/to/file.txt");
    }
    long end = System.currentTimeMillis();

    System.err.println("time to resolve " + NUOF_RESOLVES + " files: "
            + (end - start) + "ms");
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:19,代码来源:FileNamePerformance.java

示例13: testNames

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
private static void testNames(FileSystemManager mgr, FileName rootName) throws FileSystemException
{
    for (int i = 0; i < 10; i++)
    {
        // warmup jvm
        mgr.resolveName(rootName,
                "/many/path/elements/with%25esc/any%25where/to/file.txt");
    }

    long start = System.currentTimeMillis();
    for (int i = 0; i < NUOF_RESOLVES; i++)
    {
        mgr.resolveName(rootName,
                "/many/path/elements/with%25esc/any%25where/to/file.txt");
    }
    long end = System.currentTimeMillis();

    System.err.println("time to resolve " + NUOF_RESOLVES + " names: "
            + (end - start) + "ms");
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:21,代码来源:FileNamePerformance.java

示例14: getBaseTestFolder

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
/**
 * Returns the base folder for tests.
 */
@Override
public FileObject getBaseTestFolder(final FileSystemManager manager)
        throws Exception
{
    if (!inited)
    {
        // Import the test tree
        FileObject fo = manager.resolveFile("ram:/");
        RamFileSystem fs = (RamFileSystem) fo.getFileSystem();
        fs.importTree(new File(AbstractVfsTestCase.getTestDirectory()));
        fo.close();

        inited=true;
    }

    final String uri = "ram:/";
    return manager.resolveFile(uri);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:RamProviderTestCase.java

示例15: testDefaultInstance

import org.apache.commons.vfs2.FileSystemManager; //导入依赖的package包/类
/**
 * Sanity test.
 */
public void testDefaultInstance() throws Exception
{
    // Locate the default manager
    final FileSystemManager manager = VFS.getManager();

    // Lookup a test jar file
    final File jarFile = getTestResource("test.jar");
    FileObject file = manager.toFileObject(jarFile);
    assertNotNull(file);
    assertTrue(file.exists());
    assertSame(FileType.FILE, file.getType());

    // Expand it
    file = manager.createFileSystem(file);
    assertNotNull(file);
    assertTrue(file.exists());
    assertSame(FileType.FOLDER, file.getType());
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:FileSystemManagerFactoryTestCase.java


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