本文整理匯總了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;
}
示例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));
}
示例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();
}
}
示例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);
}
示例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();
}
}
}
示例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 ();
}
}
示例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);
}
示例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());
}
}
示例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());
}
}
示例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());
}
示例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");
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}