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


Java FileUtil.toFileObject方法代码示例

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


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

示例1: getProject

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static Project getProject (File[] files) {
    for (File file : files) {
        /* We may be committing a LocallyDeleted file */
        if (!file.exists()) file = file.getParentFile();
        FileObject fo = FileUtil.toFileObject(file);
        if(fo == null) {
            LOG.log(Level.FINE, "Utils.getProjectFile(): No FileObject for {0}", file); // NOI18N
        } else {
            Project p = FileOwnerQuery.getOwner(fo);
            if (p != null) {
                return p;
            } else {
                LOG.log(Level.FINE, "Utils.getProjectFile(): No project for {0}", file); // NOI18N
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Utils.java

示例2: retrieveResourceImpl

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private FileObject retrieveResourceImpl(FileObject destinationDir, 
        URI resourceToRetrieve, FileObject catalogFileObject, boolean save2singleFolder) 
        throws UnknownHostException, URISyntaxException, IOException {
    instance = new RetrieverEngineImpl(FileUtil.toFile(destinationDir), newThread);
    instance.setFileOverwrite(overwriteFiles);
    instance.setSave2SingleFolder(save2singleFolder);
    if(catalogFileObject != null)
        instance.setCatalogFile(catalogFileObject);
    instance.setShowErrorPopup(false);
    RetrieveEntry rent = null;
    rent = new RetrieveEntry(null, resourceToRetrieve.toString(), null, 
            null, DocumentTypesEnum.schema, this.retrieveRecursively);
    instance.addResourceToRetrieve(rent);
    instance.start();
    File result = instance.getSeedFileLocation();
    seedFile = result;
    if(result == null)
        return null;
    //createCatalog(result);
    return FileUtil.toFileObject(FileUtil.normalizeFile(result));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:RetrieverImpl.java

示例3: testRefreshForBoth

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testRefreshForBoth() throws Exception {
    EventsEvaluator fdc = new EventsEvaluator();                        
    try {
        File workDir = getWorkDir();
        File external = new File(workDir, "externalFile");        
        assertFalse(external.exists());
        FileObject foWorkDir = FileUtil.toFileObject(workDir);
        assertNotNull(foWorkDir);
        assertNull(foWorkDir.getFileObject(external.getName()));
        assertTrue(external.createNewFile());
        assertNull(foWorkDir.getFileObject(external.getName()));
        fdc.assertDataCreated(0);        
        FileUtil.refreshFor(external, workDir);        
        fdc.assertDataCreated(1);
        assertNotNull(foWorkDir.getFileObject(external.getName()));        
    } finally {
        fdc.cleanUp();            
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:FileObjectFactoryTest.java

示例4: testLimitAddWatchLogs

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testLimitAddWatchLogs() throws IOException {
    FileObject root = FileUtil.toFileObject(getWorkDir());
    int total = 100;

    Logger log = Logger.getLogger(Watcher.class.getName());
    Log.enable(log.getName(), Level.FINEST);
    LogCountHandler h = new LogCountHandler();

    log.addHandler(h);
    try {
        for (int i = 0; i < total; i++) {
            root.addFileChangeListener(listener);
        }
    } finally {
        log.removeHandler(h);
    }

    assertEquals("2 warnings", 2, h.warning);
    assertEquals("10 infos", 10, h.info);
    assertEquals("The rest messages are of fine level", 88, h.fine);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:WatcherLoggingTest.java

示例5: testImplsCaseOnlyRename

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testImplsCaseOnlyRename() throws IOException {
    FileObject fo = FileUtil.toFileObject(getWorkDir());
    assertNotNull(fo);
    assertNotNull(iListener);
    FileObject toRename = fo.createData("aa");
    assertNotNull(toRename);
    
    iListener.clear();
    FileLock lock = toRename.lock();
    iListener.setLock(lock);
    try {
        assertEquals(0,iListener.implsRenameCalls);
        assertEquals(0,iListener.renameImplCalls);
        iListener.setImplsRenameRetVal(true);
        assertTrue(toRename.isValid());
        assertNull(toRename.getParent().getFileObject(toRename.getExt(), toRename.getName()));
        toRename.rename(lock,toRename.getName().toUpperCase(), toRename.getExt().toUpperCase());
        assertEquals(1,iListener.implsRenameCalls);
        assertEquals(1,iListener.renameImplCalls);
    } finally {
        if (lock != null) {
            iListener.setLock(null);
            lock.releaseLock();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProvidedExtensionsTest.java

示例6: load

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static ProjectCache load (FileObject root, File f) throws IOException {
    DataInputStream is = new DataInputStream (new FileInputStream (f));
    try {
        Map<FileObject,FileCache> cache = new HashMap<FileObject, Index.FileCache> ();
        int i = is.readInt ();
        while (i > 0) {
            String path = is.readUTF ();
            File file = new File (path);
            file = FileUtil.normalizeFile (file);
            FileObject fo = FileUtil.toFileObject (file);
            FileCache fc = FileCache.load (fo, is);
            cache.put (fo, fc);
            i--;
        }
        return new ProjectCache (root, cache);
    } finally {
        is.close ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Index.java

示例7: testFindJavadocRoots

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFindJavadocRoots() throws Exception {
    FileObject root = FileUtil.toFileObject(getWorkDir());
    final Set<String> expected = new TreeSet<>();
    expected.add(TestFileUtils.writeFile(root, "lib1/dist/javadoc1/package-list", "some content").getParent().getPath());
    expected.add(TestFileUtils.writeFile(root, "lib2/dist/javadoc2/package-list", "some content").getParent().getPath());
    expected.add(TestFileUtils.writeFile(root, "lib2/dist/javadoc3/package-list", "some content").getParent().getPath());
    expected.add(TestFileUtils.writeFile(root, "other/lib/dist/javadoc4/package-list", "some content").getParent().getPath());
    final Collection< ? extends FileObject> javadocRoots = JavadocAndSourceRootDetection.findJavadocRoots(root, null);
    final Set<String> result = new TreeSet<>();
    for (FileObject jr : javadocRoots) {
        result.add(jr.getPath());
    }
    assertEquals(expected, result);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JavadocAndSourceRootDetectionTest.java

示例8: ALT_Bug129494_2Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_Bug129494_2Test(String name) {
    super(name);
    try {
        className = this.getClass().getName();
        className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_Bug129494_2Test.java

示例9: ALT_ClosedPosition02Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_ClosedPosition02Test(String name) {
    super(name);
    try {
 className = this.getClass().getName();
 className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_ClosedPosition02Test.java

示例10: copyAdditionalData

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
protected void copyAdditionalData() throws Exception {
    super.copyAdditionalData();
    FileObject out = packageRoot;
    FileObject src = FileUtil.toFileObject(getDataDir());
    src = src.getFileObject("org/netbeans/test/java/hints/pkg");
    FileUtil.copyFile(src, out, src.getName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ErrorHintsTest.java

示例11: testTransactionalFlush

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testTransactionalFlush() throws Exception {
    requireFullIndex(true);
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    FileObject indexDir = workDir.createFolder("index");
    File binaryAnalyzerDataDir = new File(getDataDir(), "Annotations.jar");

    final Index index = IndexManager.createIndex(FileUtil.toFile(indexDir), DocumentUtil.createAnalyzer());
    BinaryAnalyser a = new BinaryAnalyser(
        new IndexWriter(index) {
            @Override
            public void deleteAndFlush(List<Pair<Pair<BinaryName, String>, Object[]>> refs, Set<Pair<String, String>> toDelete) throws IOException {
                super.deleteAndFlush(refs, toDelete);
            try {
                dataFlushed(index);
            } catch (InterruptedException ex) {
                Exceptions.printStackTrace(ex);
            }
            }
        }, getWorkDir()
    );

    LowMemoryWatcherAccessor.setLowMemory(true);
    assertTrue(a.analyse(FileUtil.getArchiveRoot(Utilities.toURI(binaryAnalyzerDataDir).toURL())).done);
    // at least one flush occured.
    assertFalse(flushCount == 0);

    assertReference(index, "annotations.NoArgAnnotation", "usages.ClassAnnotations", "usages.MethodAnnotations", "usages.FieldAnnotations");
    assertReference(index, "annotations.ArrayOfStringArgAnnotation", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations");
    assertReference(index, "annotations.TestEnum", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations");
    assertReference(index, "java.util.List", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:BinaryAnalyserTest.java

示例12: ALT_GapsOptimization6Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_GapsOptimization6Test(String name) {
    super(name);
    try {
        className = this.getClass().getName();
        className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_GapsOptimization6Test.java

示例13: ALT_Positioning05Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_Positioning05Test(String name) {
    super(name);
    try {
 className = this.getClass().getName();
 className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_Positioning05Test.java

示例14: ALT_ParallelPosition26Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_ParallelPosition26Test(String name) {
    super(name);
    try {
        className = this.getClass().getName();
        className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_ParallelPosition26Test.java

示例15: ALT_Resizing12Test

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public ALT_Resizing12Test(String name) {
    super(name);
    try {
 className = this.getClass().getName();
 className = className.substring(className.lastIndexOf('.') + 1, className.length());
        startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
    } catch (IOException ioe) {
        fail(ioe.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ALT_Resizing12Test.java


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