本文整理了Java中org.openide.filesystems.FileUtil.toFileObject()
方法的一些代码示例,展示了FileUtil.toFileObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.toFileObject()
方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:toFileObject
[英]Converts a disk file to a matching file object. This is the inverse operation of #toFile.
If you are running with org.netbeans.modules.masterfs enabled, this method should never return null for a file which exists on disk. For example, to make this method work in unit tests in an Ant-based module project, right-click Unit Test Libraries, Add Unit Test Dependency, check Show Non-API Modules, select Master Filesystem. (Also right-click the new Master Filesystem node, Edit, uncheck Include in Compile Classpath.) To ensure masterfs (or some other module that can handle the conversion) is present put following line into your module manifest:
OpenIDE-Module-Needs: org.openide.filesystems.FileUtil.toFileObject
[中]将磁盘文件转换为匹配的文件对象。这是#toFile的逆运算。
如果您正在运行org。netbeans。模块。如果启用masterfs,则对于磁盘上存在的文件,此方法不应返回null。例如,要使此方法在基于Ant的模块项目的单元测试中工作,请右键单击单元测试库,添加单元测试依赖项,选中“显示非API模块”,选择“主文件系统”。(同时右键单击新的主文件系统节点“编辑”,取消选中“包含在编译类路径中”。)为确保masterfs(或其他可处理转换的模块)存在,请在模块清单中放入以下行:
OpenIDE-Module-Needs: org.openide.filesystems.FileUtil.toFileObject
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
void locateCurrent() {
FileObject oldCurrent = current;
currentF = FileUtil.normalizeFile(path);
while (true) {
current = FileUtil.toFileObject(currentF);
if (current != null) {
isOnTarget = path.equals(currentF);
break;
}
currentF = currentF.getParentFile();
if (currentF == null) {
// #47320: can happen on Windows in case the drive does not exist.
// (Inside constructor for Holder.) In that case skip it.
return;
}
}
assert current != null;
if (current != oldCurrent) {
if (oldCurrent != null) {
oldCurrent.removeFileChangeListener(this);
}
current.addFileChangeListener(this);
current.getChildren(); //to get events about children
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
private void setJarFile(final File aRoot, boolean refreshRoot, boolean openJar)
throws IOException, PropertyVetoException {
if (!aRoot.equals(FileUtil.normalizeFile(aRoot))) {
throw new IllegalArgumentException(
"Parameter aRoot was not " + // NOI18N
"normalized. Was " + aRoot + " instead of " + FileUtil.normalizeFile(aRoot)
setJar(tempJar);
openRequestTime = System.currentTimeMillis();
root = new File(s);
foRoot = FileUtil.toFileObject(root);
代码示例来源:origin: org.codehaus.mevenide/nb-project
public static FileObject convertURItoFileObject(URI uri) {
if (uri == null) {
return null;
}
File fil = new File(uri);
return FileUtil.toFileObject(fil);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javaee-project
FileObject getSelectedLocation() {
return FileUtil.toFileObject(new File(locationText.getText()));
}
代码示例来源:origin: org.codehaus.mevenide/nb-project
public static FileObject convertStringToFileObject(String str) {
if (str != null) {
File fil = new File(str);
fil = FileUtil.normalizeFile(fil);
return FileUtil.toFileObject(fil);
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-localhistory
/**
* Normalizes the given file and return a FileObject
* @param file
* @return
*/
public static FileObject toFileObject(File file) {
File nfile = FileUtil.normalizeFile(file);
if(nfile != null) {
return FileUtil.toFileObject(nfile);
} else {
return FileUtil.toFileObject(file);
}
}
代码示例来源:origin: dcaoyuan/nbscala
public Collection<FileObject> getInstallFolders() {
return Collections.singleton(FileUtil.toFileObject(new File(System.getProperty("scala.home")))); // NOI18N
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javacard-spi
@Override
public Collection<FileObject> getInstallFolders() {
String prop = System.getProperty("java.home"); //NOI18N
File f = FileUtil.normalizeFile (new File (prop));
return Collections.<FileObject>singleton(FileUtil.toFileObject(f));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
public LocalFileDiffStreamSource (File file, boolean isRight) {
this.file = FileUtil.normalizeFile(file);
this.fileObject = FileUtil.toFileObject(this.file);
this.isRight = isRight;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver
public File getDistributionPath(FileObject sourceFile) {
for (Iterator i=rootFiles.iterator(); i.hasNext();) {
File rootFile = (File) i.next();
FileObject root = FileUtil.toFileObject(rootFile);
String relative = FileUtil.getRelativePath(root, sourceFile);
if (relative != null && ! relative.trim().equals("")) { //NOI18N
return new File(relative);
}
}
return null;
}
}
代码示例来源:origin: org.codehaus.mevenide/nb-project
public static FileObject[] convertStringsToFileObjects(List<String> strings) {
FileObject[] fos = new FileObject[strings.size()];
int index = 0;
Iterator<String> it = strings.iterator();
while (it.hasNext()) {
String str = it.next();
File fil = new File(str);
fil = FileUtil.normalizeFile(fil);
fos[index] = FileUtil.toFileObject(fil);
index++;
}
return fos;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
/**
* Sets the file for which the annotations are displayed. This file can differ from the displayed one when showing annotations
* for a file in the past.
* @param file
*/
void setReferencedFile(File file) {
this.referencedFile = FileUtil.normalizeFile(file);
this.referencedFileObject = FileUtil.toFileObject(file);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-platform
/** Utility method. See {@link #getLibDir()}. */
public synchronized FileObject getLibDirFO() {
if (libDirFO == null) {
String lib = getLibDir();
if (lib != null) {
libDirFO = FileUtil.toFileObject(new File(lib));
}
}
return libDirFO;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
private void selectAbsoluteResource(Matcher m) {
String resource = "/" + m.group(1) + m.group(4); //NOI18N
int lineNumber = Integer.parseInt(m.group(5));
File file = new File(resource);
if (file.exists()) {
FileObject source = FileUtil.toFileObject(FileUtil.normalizeFile(file));
doOpen(source, lineNumber);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
public void openSnapshot(File snapshot) {
File sf = FileUtil.normalizeFile(snapshot);
FileObject snapshotFo = FileUtil.toFileObject(sf);
openSnapshot(snapshotFo);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
/**
* @return file object (possibly resolved to the given base folder) or {@code null} if not exists
*/
public FileObject getFileObject(FileObject baseFolder) {
return FileUtil.toFileObject(new File(getAbsoluteFilePath(baseFolder)));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform
public void setAsText(final String text) throws IllegalArgumentException {
if (text == null)
throw new IllegalArgumentException();
File f = new File(text);
f = FileUtil.normalizeFile(f);
final FileObject fo = FileUtil.toFileObject(f);
if (fo == null)
throw new IllegalArgumentException();
setValue(fo);
}
代码示例来源:origin: org.codehaus.mevenide/nb-project
public FileObject getRootFolder() {
FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(art.getFile()));
if (fo != null) {
return FileUtil.getArchiveRoot(fo);
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
private boolean isUnderneathSourcesOnlyAndVisible(String path) {
return isUnderneathSourcesOnlyAndVisible(FileUtil.toFileObject(new File(path)));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-grailsproject
@Override
protected FileObject getTargetFO(String fileName, FileObject sourceFO) {
File targetFile = new File(getTargetFilePath(fileName, sourceFO));
FileObject targetFO = FileUtil.toFileObject(FileUtil.normalizeFile(targetFile));
// do not navigate to itself
if (sourceFO.equals(targetFO)) {
return null;
}
return targetFO;
}
内容来源于网络,如有侵权,请联系作者删除!