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


Java FileObject.delete方法代码示例

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


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

示例1: overwriteDBSchema

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Overwrites <code>dbschemaFile</code> with the contents of
 * <code>schemaElement</code>.
 */
private static void overwriteDBSchema(SchemaElement schemaElement, FileObject dbschemaFile, DBIdentifier dbschemaName) throws IOException {
    try {
        schemaElement.setName(dbschemaName);
    } catch (DBException e) {
        IOException ioe = new IOException(e.getMessage());
        ioe.initCause(e);
        throw ioe;
    }

    // cannot just overwrite the file, DBSchemaDataObject would not
    // notice the file has changed.
    FileObject parent = dbschemaFile.getParent();
    String fileName = dbschemaFile.getName();
    String fileExt = dbschemaFile.getExt();
    dbschemaFile.delete();
    FileObject newDBSchemaFile = parent.createData(fileName, fileExt);

    writeSchemaElement(schemaElement, newDBSchemaFile);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DBSchemaManager.java

示例2: testDelete2

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDelete2() throws IOException {
    File f = testFile;
    
    FileObject testFo = FileBasedFileSystem.getFileObject(testFile);
    assertNotNull(testFo);
    assertEquals(0,testFo.getChildren().length);
    
    FileObject newFolder = testFo.createFolder("testDelete2");
    assertNotNull(newFolder);
    assertEquals(1,testFo.getChildren().length);
    
    newFolder.delete();
    assertFalse(newFolder.isValid());
    assertEquals(0,testFo.getChildren().length);
    assertNull(testFo.getFileObject(newFolder.getNameExt()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FolderObjTest.java

示例3: closeMemoryToolbar

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
     * Close Memory Toolbar.
     */
    public static void closeMemoryToolbar(){
        // View|Toolbars|Memory        
        try {  // workaround for Issue #213828
            FileObject fo = FileUtil.getConfigFile("Toolbars/Memory");
            if (fo!=null) {
                fo.delete();
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }        
//        closeToolbar(Bundle.getStringTrimmed("org.openide.actions.Bundle","View") + "|" +
//                Bundle.getStringTrimmed("org.netbeans.core.windows.actions.Bundle", "CTL_ToolbarsListAction") + "|" +
//                "Memory");
        maximizeWholeNetbeansWindow();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CommonUtilities.java

示例4: load

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static void load() throws IOException {
    FileObject ser = getLoaderPoolStorage(false);
    if (ser != null) {
        try {
            ObjectInputStream ois = new NbObjectInputStream(ser.getInputStream());
            try {
                NbObjectInputStream.readSafely(ois);
            } finally {
                ois.close();
            }
        } catch (IOException x) {
            ser.delete(); // #144158: probably not valuable, just kill it
            throw x;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbLoaderPool.java

示例5: testLockFileAfterCrash

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testLockFileAfterCrash() throws Exception {
    FileObject testFo = FileUtil.createData(root,"/testAfterCrash/testfile.data");
    File testFile = FileUtil.toFile(testFo);
  
    
    File lockFile = WriteLockUtils.getAssociatedLockFile(testFile);
    if (!lockFile.exists()) {
        assertTrue(lockFile.createNewFile());
    }
            
    assertTrue(lockFile.exists());

    FileObject lockFo = FileUtil.toFileObject(lockFile);        
    assertNull(lockFo);        
    testFo.delete();        
    
    
    lockFo = FileUtil.toFileObject(lockFile);        
    String msg = (lockFo != null) ? lockFo.toString() : "";
    assertNull(msg,lockFo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BaseFileObjectTestHid.java

示例6: testCreateNodeForInvalidDataObject

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Test for bug 217984.
 */
public void testCreateNodeForInvalidDataObject() throws IOException {
    ResultModel rm = SearchTestUtils.createResultModelWithOneMatch();
    MatchingObject mo = rm.getMatchingObjects().get(0);
    DataObject dob = mo.getDataObject();
    FileObject fob = mo.getFileObject();
    Node original = dob.getNodeDelegate();
    fob.delete();
    // No exception should be thrown from the constructor.
    Node n = new MatchingObjectNode(original, Children.LEAF, mo, false);
    assertEquals("test.txt", n.getDisplayName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:MatchingObjectNodeTest.java

示例7: deleteCacheRoot

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void deleteCacheRoot(Reference<JShellEnvironment> ref, FileObject f) {
    synchronized (this) {
        if (fileIndex.get(f) != ref) {
            // reused.
            return;
        }
        fileIndex.remove(f);
        try {
            f.delete();
        } catch (IOException ex) {
            LOG.log(Level.WARNING, "Could not delete work root {0}: {1}", new Object[] { f, ex });
            ignoreNames.add(f.getNameExt());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ShellRegistry.java

示例8: deleteProfile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public void deleteProfile (String profile) {
    FileObject root = FileUtil.getConfigFile(KEYMAPS_FOLDER);
    if (root == null) return;
    root = root.getFileObject (profile);
    if (root == null) return;
    try {
        root.delete ();
    } catch (IOException ex) {
        ErrorManager.getDefault ().notify (ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:LayersBridge.java

示例9: testInterceptor

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testInterceptor() throws IOException {
    File newFile = new File(rootDir, "vcs-tck-created.txt");
    assertFalse(newFile.exists());
    FileObject fo = FileUtil.toFileObject(rootDir);

    // test creation
    FileObject newfo = fo.createData("vcs-tck-created.txt");
    
    sleep(1000);

    // test delete
    newfo.delete();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VersioningSystemTest.java

示例10: testModuleSourcesChangesFires

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testModuleSourcesChangesFires() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject modulesFolder = wd.createFolder("modules"); //NOI18N
    assertNotNull(modulesFolder);
    final FileObject classesFolder = modulesFolder.createFolder("module").createFolder("classes");        //NOI18N
    assertTrue(mtu.updateModuleRoots(false, "classes:resources",modulesFolder));   //NOI18N
    final SourceRoots modules = mtu.newModuleRoots(false);
    assertTrue(Arrays.equals(new FileObject[]{modulesFolder}, modules.getRoots()));
    final SourceRoots sources = mtu.newSourceRoots(false);
    assertEquals(
            Arrays.stream(new FileObject[]{classesFolder})
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()),
            Arrays.stream(sources.getRoots())
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()));
    final MultiModule model = MultiModule.getOrCreate(modules, sources);
    assertNotNull(model);
    ClassPath scp = model.getModuleSources("module");   //NOI18N
    assertNotNull(scp);
    assertEquals(Arrays.asList(classesFolder), Arrays.asList(scp.getRoots()));

    final MockPropertyChangeListener l = new MockPropertyChangeListener();
    scp.addPropertyChangeListener(l);
    final FileObject resourcesFolder = modulesFolder.getFileObject("module").createFolder("resources");        //NOI18N
    l.assertEvents(ClassPath.PROP_ROOTS);

    classesFolder.delete();
    l.assertEvents(ClassPath.PROP_ROOTS);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:MultiModuleTest.java

示例11: setUp

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    root = FileUtil.getConfigRoot();
    for (FileObject f : root.getChildren()) {
        f.delete();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ProcessorTest.java

示例12: deleteFileImpl

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void deleteFileImpl(File workDir, String path) throws IOException{
    FileObject fo = FileUtil.toFileObject(new File(workDir, path));
    if (fo == null) {
        fo = FileUtil.getConfigFile(path); // NOI18N
        if (fo == null){
            return;
        }
    }
    fo.delete();        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TestUtilities.java

示例13: testNewCompilationUnitFromNonExistingTemplate

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testNewCompilationUnitFromNonExistingTemplate() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");

    File fakeFile = new File(getWorkDir(), "Fake.java");
    FileObject fakeFO = FileUtil.createData(fakeFile);

    FileObject template = FileUtil.getConfigFile("Templates/Classes/Class.java");
    if (template != null) template.delete();
    template = FileUtil.getConfigFile("Templates/Classes/Empty.java");
    if(template != null) template.delete();

    FileObject testSourceFO = FileUtil.createData(testFile); assertNotNull(testSourceFO);
    ClassPath sourcePath = ClassPath.getClassPath(testSourceFO, ClassPath.SOURCE); assertNotNull(sourcePath);
    FileObject[] roots = sourcePath.getRoots(); assertEquals(1, roots.length);
    final FileObject sourceRoot = roots[0]; assertNotNull(sourceRoot);
    ClassPath compilePath = ClassPath.getClassPath(testSourceFO, ClassPath.COMPILE); assertNotNull(compilePath);
    ClassPath bootPath = ClassPath.getClassPath(testSourceFO, ClassPath.BOOT); assertNotNull(bootPath);
    ClasspathInfo cpInfo = ClasspathInfo.create(bootPath, compilePath, sourcePath);
    JavaSource javaSource = JavaSource.create(cpInfo, fakeFO);

    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void cancel() {
        }

        public void run(WorkingCopy workingCopy) throws Exception {
            workingCopy.toPhase(JavaSource.Phase.PARSED);
            TreeMaker make = workingCopy.getTreeMaker();
            String path = "zoo/Krtek.java";
            GeneratorUtilities genUtils = GeneratorUtilities.get(workingCopy);
            CompilationUnitTree newTree = genUtils.createFromTemplate(sourceRoot, path, ElementKind.CLASS);
            workingCopy.rewrite(null, newTree);
        }
    };
    ModificationResult result = javaSource.runModificationTask(task);
    result.commit();

    String res = TestUtilities.copyFileToString(new File(getDataDir().getAbsolutePath() + "/zoo/Krtek.java"));
    assertEquals(res, "package zoo;\n\n");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:CompilationUnitTest.java

示例14: testInterfaceFoundInMyServices

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testInterfaceFoundInMyServices() throws Exception {
    assertNull("not found", Lookup.getDefault().lookup(Shared.class));
    FileObject fo = FileUtil.createData(root, "MyServices/sub/dir/2/" + Shared.class.getName().replace('.', '-') + ".instance");
    assertNotNull("found", Lookup.getDefault().lookup(Shared.class));
    fo.delete();
    assertNull("not found again", Lookup.getDefault().lookup(Shared.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:FSFoldersInLookupTest.java

示例15: testModuleSourcesChanges

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testModuleSourcesChanges() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject modulesFolder = wd.createFolder("modules"); //NOI18N
    assertNotNull(modulesFolder);
    final FileObject classesFolder = modulesFolder.createFolder("module").createFolder("classes");        //NOI18N
    assertTrue(mtu.updateModuleRoots(false, "classes:resources",modulesFolder));   //NOI18N
    final SourceRoots modules = mtu.newModuleRoots(false);
    assertTrue(Arrays.equals(new FileObject[]{modulesFolder}, modules.getRoots()));
    final SourceRoots sources = mtu.newSourceRoots(false);
    assertEquals(
            Arrays.stream(new FileObject[]{classesFolder})
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()),
            Arrays.stream(sources.getRoots())
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()));
    final MultiModule model = MultiModule.getOrCreate(modules, sources);
    assertNotNull(model);
    ClassPath scp = model.getModuleSources("module");   //NOI18N
    assertNotNull(scp);
    assertEquals(Arrays.asList(classesFolder), Arrays.asList(scp.getRoots()));

    final FileObject resourcesFolder = modulesFolder.getFileObject("module").createFolder("resources");        //NOI18N
    assertEquals(Arrays.asList(classesFolder, resourcesFolder), Arrays.asList(scp.getRoots()));

    classesFolder.delete();
    assertEquals(Arrays.asList(resourcesFolder), Arrays.asList(scp.getRoots()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:MultiModuleTest.java


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