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

Java FileSystem类代码示例

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

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



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

示例1: setFiles

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
    fileSystemListeners = new HashSet<FileStatusListener>();
    this.files = files;
    if (files == null) {
        return;
    }
    Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
    for (FileObject fo : files) {
        try {
            FileSystem fs = fo.getFileSystem();
            if (hookedFileSystems.contains(fs)) {
                continue;
            }
            hookedFileSystems.add(fs);
            FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
            fs.addFileStatusListener(fsl);
            fileSystemListeners.add(fsl);
        } catch (FileStateInvalidException e) {
            ErrorManager err = ErrorManager.getDefault();
            err.annotate(e, "Cannot get " + fo + " filesystem, ignoring...");  // NOI18N
            err.notify(ErrorManager.INFORMATIONAL, e);
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:25,代码来源:AnnotatedNode.java


示例2: getLoaderDisplayName

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/** Returns localized display name of loader for given MIME type or null if not defined. */
private static String getLoaderDisplayName(String mimeType) {
    FileSystem filesystem = null;
    try {
        filesystem = FileUtil.getConfigRoot().getFileSystem();
    } catch (FileStateInvalidException ex) {
        Exceptions.printStackTrace(ex);
    }
    FileObject factoriesFO = FileUtil.getConfigFile("Loaders/" + mimeType + "/Factories");  //NOI18N
    if(factoriesFO != null) {
        FileObject[] children = factoriesFO.getChildren();
        for (FileObject child : children) {
            String childName = child.getNameExt();
            String displayName = filesystem.getDecorator().annotateName(childName, Collections.singleton(child));
            if(!childName.equals(displayName)) {
                return displayName;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FileAssociationsModel.java


示例3: PackageRootNode

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
private PackageRootNode( SourceGroup group, Children ch) {
    super(ch, new ProxyLookup(createLookup(group), Lookups.singleton(
            SearchInfoDefinitionFactory.createSearchInfoBySubnodes(ch))));
    this.group = group;
    file = group.getRootFolder();
    files = Collections.singleton(file);
    try {
        FileSystem fs = file.getFileSystem();
        fileSystemListener = FileUtil.weakFileStatusListener(this, fs);
        fs.addFileStatusListener(fileSystemListener);
    } catch (FileStateInvalidException e) {            
        Exceptions.printStackTrace(Exceptions.attachMessage(e,"Can not get " + file + " filesystem, ignoring...")); //NOI18N
    }
    setName( group.getName() );
    setDisplayName( group.getDisplayName() );        
    // setIconBase("org/netbeans/modules/java/j2seproject/ui/resources/packageRoot");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PackageRootNode.java


示例4: setUp

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    FileSystem fs = FileUtil.createMemoryFileSystem();
    FileObject fo = fs.getRoot().createData("JFrame.java");
    
    source = convertStreamToString(getClass().getResourceAsStream("resources/JFrame.txt"));
    
    writeFile(source, fo);
    DataObject sourceDataObject = DataObject.find(fo);
    
    EditorCookie editorCookie = sourceDataObject.getCookie(EditorCookie.class);        
    if (editorCookie == null) {
        throw new IllegalArgumentException("I18N: Illegal data object type"+ sourceDataObject); // NOI18N
    }        
    StyledDocument document = editorCookie.getDocument();
    while(document == null) {
        document = editorCookie.openDocument();
    }        
                    
    instance = new JavaI18nFinder(document);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaI18nFinderTest.java


示例5: createDataObjectWithContent

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
private DataObject createDataObjectWithContent(byte singleByteContent)
        throws IOException {
    FileSystem fs = FileUtil.createMemoryFileSystem();
    FileObject fob = fs.getRoot().createData("test.txt");
    OutputStream os = fob.getOutputStream();
    try {
        os.write(new byte[]{singleByteContent});
    } finally {
        os.close();
    }
    DataObject dob = DataObject.find(fob);
    if (!(dob instanceof DefaultDataObject)) {
        fail("Expected an instance of DefaultDataObject");
    }
    return dob;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DefaultDataObjectTest.java


示例6: getCachedLayers

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/**
 * Returns possibly cached list of filesystems representing the XML layers of the supplied platform module JARs.
 * If cache is not ready yet, this call blocks until the cache is created.
 * Layer filesystems are already ordered to handle masked ("_hidden") files correctly.
 * @param platformJars
 * @return List of read-only layer filesystems
 * @throws java.io.IOException
 */
private Collection<FileSystem> getCachedLayers(File rootDir, final Set<File> platformJars) throws IOException {
    if (rootDir == null) {
        return Collections.emptySet();
    }
    File[] clusters = rootDir.listFiles(new FileFilter() {
        @Override public boolean accept(File pathname) {
            return ClusterUtils.isValidCluster(pathname);
        }
    });
    Collection<FileSystem> cache = PlatformLayersCacheManager.getCache(clusters, new FileFilter() {
        @Override public boolean accept(File jar) {
            return platformJars.contains(jar);
        }
    });
    return cache;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NbModuleProviderImpl.java


示例7: setUp

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
protected void setUp () throws Exception {
    clearWorkDir();

    MockServices.setServices(new Class[] {ErrManager.class, Pool.class});
    
    if (previous != null) {
        previous.waitFinished ();
    }
    
    TestUtilHid.destroyLocalFileSystem (getName());
    String fsstruct [] = new String [] {
        "AA/X.txt",
        "AA/Y.txt",
        "BB/X.slow",
    };
    
    FileSystem lfs = TestUtilHid.createLocalFileSystem (getWorkDir (), fsstruct);

    aa = DataFolder.findFolder (lfs.findResource ("AA"));
    bb = DataFolder.findFolder (lfs.findResource ("BB"));    
    
    aa.addPropertyChangeListener (this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DataFolderSetOrderTest.java


示例8: testXMLMultiFS

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testXMLMultiFS() throws Exception {
    clearWorkDir();
    // b-layer.xml overrides a-layer.xml now and then:
    List<File> files = new ArrayList<File>(Arrays.asList(
            new File(getDataDir(), "layers/b-layer.xml"),
            new File(getDataDir(), "layers/a-layer.xml")
            ));

    FileSystem xfs0 = new XMLFileSystem(Utilities.toURI(files.get(0)).toURL());
    FileSystem xfs1 = new XMLFileSystem(Utilities.toURI(files.get(1)).toURL());
    FileSystem mfs = new MultiFileSystem(xfs0, xfs1);
    assertNotNull(xfs1.findResource("Menu/A Folder"));
    assertNotNull(mfs.findResource("Menu/File"));
    assertNotNull(mfs.findResource("Menu/A Folder"));
    assertNull(mfs.findResource("Menu/A Folder/org-example-a-AAction.shadow"));  // hidden by b-layer
    FileObject mf = mfs.findResource("Actions/File");
    assertEquals(2, mf.getChildren().length);
    FileObject ba = mfs.findResource("Actions/File/org-example-b-BAction.instance");
    assertEquals("BBBBB", ba.getAttribute("displayName"));
    FileObject aa = mfs.findResource("Actions/File/org-example-a-AAction.instance");
    assertEquals("AAAA", aa.getAttribute("displayName"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:LayerUtilsTest.java


示例9: testCachedMultiFS

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testCachedMultiFS() throws Exception {
    clearWorkDir();
    LayerCacheManager m = LayerCacheManager.manager(true);
    // b-layer.xml overrides a-layer.xml now and then:
    List<File> files = new ArrayList<File>(Arrays.asList(
            new File(getDataDir(), "layers/b-layer.xml"),
            new File(getDataDir(), "layers/a-layer.xml")
            ));

    FileSystem cfs = memoryStoreAndLoad(m, files);
    assertNotNull(cfs.findResource("Menu/File"));
    assertNotNull(cfs.findResource("Menu/A Folder"));
    assertNull(cfs.findResource("Menu/A Folder/org-example-a-AAction.shadow"));  // hidden by b-layer
    FileObject mf = cfs.findResource("Actions/File");
    assertEquals(2, mf.getChildren().length);
    FileObject ba = cfs.findResource("Actions/File/org-example-b-BAction.instance");
    assertEquals("BBBBB", ba.getAttribute("displayName"));
    FileObject aa = cfs.findResource("Actions/File/org-example-a-AAction.instance");
    assertEquals("AAAA", aa.getAttribute("displayName"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:LayerUtilsTest.java


示例10: testMixedMultiFS

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testMixedMultiFS() throws Exception {
    clearWorkDir();
    LayerCacheManager m = LayerCacheManager.manager(true);
    // b-layer.xml overrides a-layer.xml now and then:
    File lb = new File(getDataDir(), "layers/b-layer.xml");
    File la = new File(getDataDir(), "layers/a-layer.xml");

    FileSystem cfs = createCachedFS(m, lb);
    FileSystem xfs = new XMLFileSystem(Utilities.toURI(la).toURL());
    FileSystem mfs = new MultiFileSystem(cfs, xfs);
    assertNotNull(mfs.findResource("Menu/File"));
    assertNotNull(mfs.findResource("Menu/A Folder"));
    assertNull(mfs.findResource("Menu/A Folder/org-example-a-AAction.shadow"));  // hidden by b-layer
    FileObject mf = mfs.findResource("Actions/File");
    assertEquals(2, mf.getChildren().length);
    FileObject ba = mfs.findResource("Actions/File/org-example-b-BAction.instance");
    assertEquals("BBBBB", ba.getAttribute("displayName"));
    FileObject aa = mfs.findResource("Actions/File/org-example-a-AAction.instance");
    assertEquals("AAAA", aa.getAttribute("displayName"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:LayerUtilsTest.java


示例11: rebuild

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/**
 * Create a new tracker for tracking mime types under the <code>basePath</code>
 * folder.
 * 
 * @param settingsType The type of settings to track mime types for. If not
 *   <code>null</code> the tracker will only list mime types that declare
 *   settings of this type.
 * @param basePath The path on the system <code>FileSystem</code> where the
 *   mime types should be tracked.
 */
/* package */ MimeTypesTracker(SettingsType.Locator locator, String basePath) {
    this.locator = locator;
    this.basePath = basePath;
    this.basePathElements = basePath.split("/"); //NOI18N
    
    rebuild();
    
    // Start listening
    this.listener = new Listener();
    FileSystem sfs = null;
    try {
        sfs = FileUtil.getConfigRoot().getFileSystem();
    } catch (FileStateInvalidException ex) {
        Exceptions.printStackTrace(ex);
    }
    sfs.addFileChangeListener(WeakListeners.create(FileChangeListener.class,listener, sfs));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:MimeTypesTracker.java


示例12: isFinishable

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
static boolean isFinishable(FileSystem fs, String buildContext, String dockerfile) {
    if (buildContext == null) {
        return false;
    }
    String realDockerfile;
    if (dockerfile == null) {
        realDockerfile = buildContext + "/" + DockerAction.DOCKER_FILE;
    } else {
        realDockerfile = buildContext + "/" + dockerfile;
    }
    FileObject build = fs.getRoot().getFileObject(buildContext);
    FileObject fo = fs.getRoot().getFileObject(realDockerfile);
    // the last check avoids entires like Dockerfile/ to be considered valid files
    if (fo == null || !fo.isData() || !realDockerfile.endsWith(fo.getNameExt())) {
        return false;
    }
    if (build == null) {
        return false;
    }
    return FileUtil.isParentOf(build, fo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BuildImageWizard.java


示例13: testGetIteratorHonoursDataObjectsCookies

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/** Does getIterator honours DataObject's cookies?
 */
public void testGetIteratorHonoursDataObjectsCookies () throws Exception {
    FileSystem fs = FileUtil.createMemoryFileSystem();
    DataObject obj;
    Loader l = Loader.findObject (Loader.class, true);
    try {
        AddLoaderManuallyHid.addRemoveLoader (l, true);
        obj = DataObject.find (fs.getRoot ());
    } finally {
        AddLoaderManuallyHid.addRemoveLoader (l, false);
    }
    
    TemplateWizard.Iterator it = TemplateWizard.getIterator (obj);
    
    assertEquals ("Iterator obtained from the object's cookie", obj, it);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TemplateWizardTest.java


示例14: getURL

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public @Override URL getURL(FileObject fo, int type) {
    if (type != URLMapper.INTERNAL) {
        return null;
    }
    try {
        FileSystem fs = fo.getFileSystem();
        if (fs instanceof SourceFS) {
            String path = fo.getPath();
            if (fo.isFolder() && !fo.isRoot()) {
                path += '/';
            }
            return url((SourceFS) fs, path);
        }
    } catch (FileStateInvalidException x) {
        // ignore
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SourceURLMapper.java


示例15: testHandleDataShadow

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testHandleDataShadow() throws Exception {
    String fsstruct [] = new String [] {
        "AA/",
        "BB/",
        "BB/java-io-IOException.instance"
    };
    TestUtilHid.destroyLocalFileSystem (getName());
    FileSystem lfs = TestUtilHid.createLocalFileSystem (getWorkDir(), fsstruct);

    FileObject aa = lfs.findResource("/AA");
    FileObject bb = lfs.findResource("/BB");

    DataFolder a = DataFolder.findFolder (aa);
    DataFolder b = DataFolder.findFolder (bb);

    b.createShadow(a);

    FolderLookup fl = new FolderLookup(b);
    IOException io = fl.getLookup().lookup(IOException.class);

    assertNotNull("IO Exception found", io);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FolderLookupTest.java


示例16: rememberConfigurations

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
private void rememberConfigurations () {
    FileObject fo = project.getProjectDirectory().getFileObject(ProjectConfigurations.CONFIG_PROPS_PATH);
    if (fo != null) {
        //Has configurations
        try {
            FileSystem fs = FileUtil.createMemoryFileSystem();
            FileUtil.copyFile(fo, fs.getRoot(),fo.getName());
            fo = project.getProjectDirectory().getFileObject("nbproject/private/configs");      //NOI18N
            if (fo != null && fo.isFolder()) {
                FileObject cfgs = fs.getRoot().createFolder("configs");                         //NOI18N
                for (FileObject child : fo.getChildren()) {
                    FileUtil.copyFile(child, cfgs, child.getName());
                }
            }
            configs = fs;
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectOperations.java


示例17: testIndexCookieOfferedOnlyWhenAppropriate

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testIndexCookieOfferedOnlyWhenAppropriate() throws Exception {
    Node n = df.getNodeDelegate();
    assertNotNull("have an index cookie on SFS", n.getLookup().lookup(Index.class));
    LocalFileSystem lfs = new LocalFileSystem();
    lfs.setRootDirectory(getWorkDir());
    n = DataFolder.findFolder(lfs.getRoot()).getNodeDelegate();
    assertNull("have no index cookie on a local folder", n.getLookup().lookup(Index.class));
    FileSystem fs = FileUtil.createMemoryFileSystem();
    FileObject x = fs.getRoot().createFolder("x");
    FileObject y = fs.getRoot().createFolder("y");
    y.setAttribute("DataFolder.Index.reorderable", Boolean.TRUE);
    n = DataFolder.findFolder(x).getNodeDelegate();
    assertNull("have no index cookie on a random folder in a random FS", n.getLookup().lookup(Index.class));
    n = DataFolder.findFolder(y).getNodeDelegate();
    assertNotNull("do have index cookie if magic attr is set", n.getLookup().lookup(Index.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DataFolderIndexTest.java


示例18: testAllLastModifiedCheck

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testAllLastModifiedCheck() throws Exception {
    clearWorkDir();
    LayerCacheManager m = createManager();
    // layer2.xml should override layer1.xml where necessary:
    List<URL> urls = Arrays.asList(
            loadResource("data/layer2.xml"),
            loadResource("data/layer1.xml"));
    FileSystem f = BinaryCacheManagerTest.store(m, urls);
    
    Enumeration<? extends FileObject> en = f.getRoot().getChildren(true);
    final long myTime = Stamps.getModulesJARs().lastModified();
    if (myTime <= 0) {
        fail("Something is wrong, stamps are not valid: " + myTime);
    }
    
    CountingSecurityManager.initialize(getWorkDirPath(), CountingSecurityManager.Mode.CHECK_READ, null);
    CountingSecurityManager.acceptAll = true;
    while (en.hasMoreElements()) {
        FileObject fo = en.nextElement();
        final long time = fo.lastModified().getTime();
        assertEquals("Time stamp is like Stamps: " + fo, myTime, time);
    }
    CountingSecurityManager.assertCounts("No reads at all", 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:BinaryCacheManagerViaJarTest.java


示例19: testLocalFileSystemEx133616

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/** Simulates deadlock issue 133616
 * - create MultiFileSystem
 * - create lookup to set our MultiFileSystem and system filesystem
 * - create handler to manage threads
 * - put test FileObject to 'potentialLock' set
 * - call hasLocks
 *   - it call LocalFileSystemEx.getInvalid which ends in our DeadlockHandler
 *   - it starts lockingThread which calls FileObject.lock which locks our FileObject
 *   - when we in LocalFileSystemEx.lock, we notify main thread which continues
 *     in getInvalid and tries to accuire lock on FileObject and it dead locks
 */
public void testLocalFileSystemEx133616() throws Exception {
    System.setProperty("workdir", getWorkDirPath());
    clearWorkDir();

    FileSystem lfs = TestUtilHid.createLocalFileSystem("mfs1" + getName(), new String[]{"/fold/file1"});
    LocalFileSystemEx exfs = new LocalFileSystemEx();
    exfs.setRootDirectory(FileUtil.toFile(lfs.getRoot()));
    FileSystem xfs = TestUtilHid.createXMLFileSystem(getName(), new String[]{});
    FileSystem mfs = new MultiFileSystem(exfs, xfs);
    testedFS = mfs;
    Lookup l = Lookup.getDefault();
    if (!(l instanceof Lkp)) {
        fail("Wrong lookup: " + l);
    }
    ((Lkp)l).init();

    final FileObject file1FO = mfs.findResource("/fold/file1");
    File file1File = FileUtil.toFile(file1FO);

    Logger.getLogger(LocalFileSystemEx.class.getName()).setLevel(Level.FINEST);
    Logger.getLogger(LocalFileSystemEx.class.getName()).addHandler(new DeadlockHandler(file1FO));
    LocalFileSystemEx.potentialLock(file1FO.getPath());
    LocalFileSystemEx.hasLocks();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:LocalFileSystemEx133616Test.java


示例20: testNBResLocURL

import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testNBResLocURL() throws Exception {
    Map<String, String> files = new HashMap<String, String>();
    files.put("org/test/x.txt", "stuff");
    files.put("org/test/resources/y.txt", "more stuff");
    Layer orig = new Layer("<file name='x' url='nbres:/org/test/x.txt'/><file name='y' url='nbresloc:/org/test/resources/y.txt'/>", files);
    FileObject orgTest = FileUtil.createFolder(new File(orig.folder, "org/test"));
    FileObject lf = orig.f.copy(orgTest, "layer", "xml");
    SavableTreeEditorCookie cookie = LayerUtils.cookieForFile(lf);
    FileSystem fs = new WritableXMLFileSystem(lf.toURL(), cookie,
            ClassPathSupport.createClassPath(new FileObject[] { FileUtil.toFileObject(orig.folder) } ));
    FileObject x = fs.findResource("x");
    assertNotNull(x);
    assertTrue(x.isData());
    assertEquals(5L, x.getSize());
    assertEquals("stuff", x.asText("UTF-8"));

    FileObject y = fs.findResource("y");
    assertNotNull(y);
    assertTrue(y.isData());
    assertEquals(10L, y.getSize());
    assertEquals("more stuff", y.asText("UTF-8"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:WritableXMLFileSystemTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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