本文整理匯總了Java中org.openide.filesystems.FileUtil.createFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.createFolder方法的具體用法?Java FileUtil.createFolder怎麽用?Java FileUtil.createFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.createFolder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCosScript
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@NonNull
private FileObject getCosScript() throws IOException {
final FileObject snippets = FileUtil.createFolder(
Places.getCacheSubdirectory(SNIPPETS));
FileObject cosScript = snippets.getFileObject(SCRIPT);
if (cosScript == null) {
cosScript = FileUtil.createData(snippets, SCRIPT);
final FileLock lock = cosScript.lock();
try (InputStream in = getClass().getResourceAsStream(SCRIPT_TEMPLATE);
OutputStream out = cosScript.getOutputStream(lock)) {
FileUtil.copy(in, out);
} finally {
lock.releaseLock();
}
}
return cosScript;
}
示例2: getDefault
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Returns default toolbar pool.
* @return default system pool
*/
public static synchronized ToolbarPool getDefault () {
if (defaultPool == null) {
FileObject root = FileUtil.getConfigRoot();
FileObject fo = null;
try {
fo = FileUtil.createFolder(root, "Toolbars"); // NOI18N
} catch (IOException ex) {
Logger.getLogger(ToolbarPool.class.getName()).log(Level.CONFIG, "Cannot create Toolbars folder.", ex);
}
if (fo == null)
throw new IllegalStateException("No Toolbars/"); // NOI18N
DataFolder folder = DataFolder.findFolder(fo);
defaultPool = new ToolbarPool(folder);
// we mustn't do this in constructor to prevent from
// nevereding recursive calls to this method.
defaultPool.instance.recreate();
}
return defaultPool;
}
示例3: testWaitsForToolbars
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@RandomlyFails // NB-Core-Build #1337
public void testWaitsForToolbars () throws Exception {
FileObject tlb = FileUtil.createFolder (toolbars, "tlbx");
DataFolder f = DataFolder.findFolder (tlb);
InstanceDataObject.create (f, "test1", JLabel.class);
ToolbarPool tp = ToolbarPool.getDefault ();
Toolbar[] myTlbs = tp.getToolbars ();
assertEquals ("One", 1, myTlbs.length);
assertEquals ("By default there is the one", "tlbx", myTlbs[0].getName ());
assertLabels ("One subcomponent", 1, myTlbs[0]);
InstanceDataObject.create (f, "test2", JLabel.class);
tp.waitFinished ();
assertLabels ("Now there are two", 2, myTlbs[0]);
}
示例4: testUnmodifiedDocumentSaveAs
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testUnmodifiedDocumentSaveAs() throws IOException {
FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
assertEquals( MyDataObject.class, obj.getClass());
assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );
MyEnv env = new MyEnv( obj );
MyDataEditorSupport des = new MyDataEditorSupport( obj, env );
FileObject newFolder = FileUtil.createFolder(FileUtil.getConfigRoot(), "otherFolder");
des.saveAs( newFolder, "newFile.newExt" );
DataObject newObj = DataObject.find(FileUtil.getConfigFile("otherFolder/newFile.newExt"));
assertEquals( MyDataObject.class, newObj.getClass());
MyDataObject myObj = (MyDataObject)newObj;
assertEquals("the original document was closed", 1, des.closeCounter );
assertEquals("we don't ask before closing the original document", 0, des.canCloseCounter );
assertEquals("new document was opened", 1, myObj.openCookieCalls);
}
示例5: prepareSourceRoot
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void prepareSourceRoot(String name, String... dependsOn) throws Exception {
FileObject src = FileUtil.createFolder(sourceDirectories, name);
FileObject build = FileUtil.createFolder(buildDirectories, name);
List<FileObject> dependencies = new LinkedList<FileObject>();
for(String dep : dependsOn) {
FileObject depFO = buildDirectories.getFileObject(dep);
assertNotNull(depFO);
dependencies.add(depFO);
}
root2ClassPath.put(src, ClassPathSupport.createClassPath(dependencies.toArray(new FileObject[0])));
root2BuildRoot.put(src, build);
buildRoot2Source.put(build, src);
}
示例6: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected void setUp() throws Exception {
super.setUp();
MockLookup.setLayersAndInstances(
new org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation()
);
scratch = TestUtil.makeScratchDir(this);
projdir = scratch.createFolder("proj");
J2SEProjectGenerator.setDefaultSourceLevel(new SpecificationVersion ("1.6")); //NOI18N
helper = J2SEProjectGenerator.createProject(FileUtil.toFile(projdir),"proj",null,null,null, false); //NOI18N
J2SEProjectGenerator.setDefaultSourceLevel(null);
sources = projdir.getFileObject("src");
tests = projdir.getFileObject("test");
dist = FileUtil.createFolder(projdir,"dist");
build = FileUtil.createFolder(projdir,"build");
pm = ProjectManager.getDefault();
Project p = pm.findProject(projdir);
assertTrue("Invalid project type",p instanceof J2SEProject);
pp = (J2SEProject) p;
}
示例7: prepareProject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void prepareProject (String platformName) throws IOException {
projdir = scratch.createFolder("proj");
final JavaPlatform[] jps = JavaPlatformManager.getDefault().getPlatforms(platformName, null);
assertEquals(1, jps.length);
final JavaPlatform jp = jps[0];
AntProjectHelper helper = new J2SEProjectBuilder(FileUtil.toFile(projdir), "Test Project") //NOI18N
.addDefaultSourceRoots()
.setJavaPlatform(jp)
.build();
pm = ProjectManager.getDefault();
final Project p = pm.findProject(projdir);
pp = p.getLookup().lookup(J2SEProject.class);
sources = FileUtil.createFolder(projdir, "src"); //NOI18N
tests = FileUtil.createFolder(projdir, "test"); //NOI18N
}
示例8: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
FileObject fo = FileUtil.createFolder(
FileUtil.getConfigRoot(),
"Folder" + getName()
);
df = DataFolder.findFolder(fo);
}
示例9: testRootCache
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testRootCache() throws IOException {
final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
final FileObject root1 = FileUtil.createFolder(wd, "root1");
final FileObject module1 = createTestFile (root1, null, "module-info.java", "module Foo {}"); //NOI18N
final FileObject java1 = createTestFile (root1, "org/nb/test", "Test.java", "package org.nb.test;\nclass Test {}"); //NOI18N
final FileObject root2 = FileUtil.createFolder(wd, "root2");
final FileObject module2 = createTestFile (root2, null, "module-info.java", "module Boo {}"); //NOI18N
final FileObject java2 = createTestFile (root2, "org/nb/test", "Test2.java", "package org.nb.test;\nclass Test2 {}"); //NOI18N
final Logger l = Logger.getLogger(DefaultSourceLevelQueryImpl.class.getName());
final Level origLogLevel = l.getLevel();
final H h = new H();
l.setLevel(Level.FINE);
l.addHandler(h);
try {
assertEquals(
expectedSourceLevel().toString(),
SourceLevelQuery.getSourceLevel(java1));
List<? extends FileObject> roots = h.getRoots();
assertEquals(1, roots.size());
assertEquals(root1, roots.get(0));
h.reset();
assertEquals(
expectedSourceLevel().toString(),
SourceLevelQuery.getSourceLevel(java1));
roots = h.getRoots();
assertEquals(0, roots.size());
h.reset();
assertEquals(
expectedSourceLevel().toString(),
SourceLevelQuery.getSourceLevel(java2));
roots = h.getRoots();
assertEquals(1, roots.size());
assertEquals(root2, roots.get(0));
} finally {
l.removeHandler(h);
l.setLevel(origLogLevel);
}
}
示例10: testDataRoot
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testDataRoot () throws Exception {
final File wd = getWorkDir();
final ClassPath cp = ClassPathSupport.createClassPath(
new URL(wd.toURI().toURL().toExternalForm()+"test1/"), //NOI18N
new URL(wd.toURI().toURL().toExternalForm()+"test2/") //NOI18N
);
final FileObject test1 = FileUtil.createData(FileUtil.toFileObject(wd), "test1"); //NOI18N
final FileObject test2 = FileUtil.createFolder(FileUtil.toFileObject(wd), "test2"); //NOI18N
assertEquals(Collections.singletonList(test2),Arrays.asList(cp.getRoots()));
}
示例11: prepareTest
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void prepareTest() throws Exception {
FileObject workdir = SourceUtilsTestUtil.makeScratchDir(this);
FileObject projectFolder = FileUtil.createFolder(workdir, "testProject");
src = FileUtil.createFolder(projectFolder, "src");
test = FileUtil.createFolder(projectFolder, "test");
FileObject cache = FileUtil.createFolder(workdir, "cache");
CacheFolder.setCacheFolder(cache);
}
示例12: testDuplicateResults3
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testDuplicateResults3() throws IOException {
FileObject root = FileUtil.createFolder(new File(getWorkDir(), "src"));
String [] paths = new String [] {
"org/pckg1/file1.txt",
"org/pckg1/pckg2/file1.txt",
"org/pckg1/pckg2/file2.txt",
};
populateFolderStructure(root, paths);
FileObjectCrawler crawler = new FileObjectCrawler(root, new FileObject[] {root.getFileObject("org/pckg1/pckg2/file1.txt"), root.getFileObject("org/pckg1/pckg2/file1.txt")}, EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, CR, SuspendSupport.NOP);
assertCollectedFiles("Wrong files collected", crawler.getResources(), new String[] {"org/pckg1/pckg2/file1.txt"});
}
示例13: testReadCategories
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testReadCategories() throws Exception {
FileObject customizerFO = FileUtil.createFolder(FileUtil.getConfigRoot(), "Projects/test/Customizer");
// - One | one
// + Category #1 | two
// - Three | three
// + Category #2 |
// - Four | four
DelegateCategoryProvider dcp = new DelegateCategoryProvider(DataFolder.findFolder(customizerFO), null);
Category categories[] = dcp.readCategories(DataFolder.findFolder(customizerFO));
assertNotNull(categories);
assertEquals(3, categories.length);
assertEquals("one", categories[0].getName());
assertEquals("One", categories[0].getDisplayName());
assertEquals("one", dcp.create(categories[0]).getName());
assertEquals("Category1", categories[1].getName());
assertEquals("Category #1", categories[1].getDisplayName());
assertEquals("two", dcp.create(categories[1]).getName());
Category[] subcategories = categories[1].getSubcategories();
assertEquals(1, subcategories.length);
assertEquals("three", subcategories[0].getName());
assertEquals("Three", subcategories[0].getDisplayName());
assertEquals("three", dcp.create(subcategories[0]).getName());
assertEquals("Category2", categories[2].getName());
assertEquals("Category #2", categories[2].getDisplayName());
assertEquals(null, dcp.create(categories[2]).getName());
subcategories = categories[2].getSubcategories();
assertEquals(1, subcategories.length);
assertEquals("four", subcategories[0].getName());
assertEquals("Four", subcategories[0].getDisplayName());
assertEquals("four", dcp.create(subcategories[0]).getName());
}
示例14: createProject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Create a new empty JavaFX project.
* @param dir the top-level directory (need not yet exist but if it does it must be empty)
* @param name the name for the project
* @param librariesDefinition project relative or absolute OS path to libraries definition; can be null
* @return the helper object permitting it to be further customized
* @throws IOException in case something went wrong
*/
public static AntProjectHelper createProject(final File dir, final String name, final String mainClass,
final String fxmlName, final String manifestFile, final String librariesDefinition,
final String platformName, final String preloader, final WizardType type) throws IOException {
Parameters.notNull("dir", dir); //NOI18N
Parameters.notNull("name", name); //NOI18N
final FileObject dirFO = FileUtil.createFolder(dir);
// if manifestFile is null => it's TYPE_LIB
final AntProjectHelper[] h = new AntProjectHelper[1];
final FileObject[] srcFolder = new FileObject[1];
dirFO.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
@Override
public void run() throws IOException {
h[0] = createProject(dirFO, name, "src", "test", mainClass, manifestFile, //NOI18N
librariesDefinition, platformName, preloader, type);
final Project p = ProjectManager.getDefault().findProject(dirFO);
JFXProjectUtils.createJfxExtension(p, dirFO, type);
ProjectManager.getDefault().saveProject(p);
if(type != WizardType.SWING) {
JFXGeneratedFilesHelper.generateBuildScriptFromStylesheet(h[0],
GeneratedFilesHelper.BUILD_XML_PATH,
JFXProjectGenerator.class.getResource("resources/build.xsl")); //NOI18N
}
final ReferenceHelper refHelper = getReferenceHelper(p);
try {
ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
@Override
public Void run() throws Exception {
copyRequiredLibraries(h[0], refHelper);
return null;
}
});
} catch (MutexException ex) {
Exceptions.printStackTrace(ex.getException());
}
srcFolder[0] = dirFO.createFolder("src"); // NOI18N
}
});
if (srcFolder[0] != null) {
createFiles(mainClass, fxmlName, srcFolder[0], type);
}
return h[0];
}
示例15: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected void setUp() throws Exception {
super.setUp();
SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
// ensure JavaKit is present, so that NbEditorDocument is eventually created.
// it handles PositionRefs differently than PlainDocument/PlainEditorKit.
MockMimeLookup.setInstances(MimePath.get("text/x-java"),
new Reindenter.Factory(), new JavaKit());
dataDir = SourceUtilsTestUtil.makeScratchDir(this);
FileObject dataTargetPackage = FileUtil.createFolder(dataDir, getSourcePckg());
assertNotNull(dataTargetPackage);
FileObject dataSourceFolder = FileUtil.toFileObject(getDataDir()).getFileObject(getSourcePckg());
assertNotNull(dataSourceFolder);
deepCopy(dataSourceFolder, dataTargetPackage);
ClassPathProvider cpp = new ClassPathProvider() {
public ClassPath findClassPath(FileObject file, String type) {
if (type == ClassPath.SOURCE)
return ClassPathSupport.createClassPath(new FileObject[] {dataDir});
if (type == ClassPath.COMPILE)
return ClassPathSupport.createClassPath(new FileObject[0]);
if (type == ClassPath.BOOT)
return createClassPath(System.getProperty("sun.boot.class.path"));
return null;
}
};
SharedClassObject loader = JavaDataLoader.findObject(JavaDataLoader.class, true);
SourceUtilsTestUtil.prepareTest(
new String[] {
"org/netbeans/modules/java/project/ui/layer.xml",
"org/netbeans/modules/project/ui/resources/layer.xml"
},
new Object[] {loader, cpp}
);
JEditorPane.registerEditorKitForContentType("text/x-java", "org.netbeans.modules.editor.java.JavaKit");
File cacheFolder = new File(getWorkDir(), "var/cache/index");
cacheFolder.mkdirs();
IndexUtil.setCacheFolder(cacheFolder);
ensureRootValid(dataDir.getURL());
TestUtil.setupEditorMockServices();
}