本文整理汇总了Java中org.openide.filesystems.FileUtil.isArchiveFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.isArchiveFile方法的具体用法?Java FileUtil.isArchiveFile怎么用?Java FileUtil.isArchiveFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.isArchiveFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public boolean accept(File f) {
if (f.isDirectory())
return true;
String name = f.getName();
int index = name.lastIndexOf('.'); //NOI18N
if (index <= 0 || index==name.length()-1)
return false;
String extension = name.substring(index+1).toUpperCase();
if (!this.extensions.contains(extension)) {
return false;
}
try {
return FileUtil.isArchiveFile (Utilities.toURI(f).toURL());
} catch (MalformedURLException e) {
Exceptions.printStackTrace(e);
return false;
}
}
示例2: findPackageRootsByName
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
static Map<String,FileObject> findPackageRootsByName(AntProjectHelper helper, PropertyEvaluator evaluator, List<String> packageRootNames) {
Map<String,FileObject> roots = new LinkedHashMap<String,FileObject>();
Iterator it = packageRootNames.iterator();
while (it.hasNext()) {
String location = (String) it.next();
String locationEval = evaluator.evaluate(location);
if (locationEval != null) {
File locationFile = helper.resolveFile(locationEval);
FileObject locationFileObject = FileUtil.toFileObject(locationFile);
if (locationFileObject != null) {
if (FileUtil.isArchiveFile(locationFileObject)) {
locationFileObject = FileUtil.getArchiveRoot(locationFileObject);
}
roots.put(location, locationFileObject);
}
}
}
return roots;
}
示例3: sysProp2CP
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static ClassPath sysProp2CP(String propname) {
String sbcp = System.getProperty(propname);
if (sbcp == null) {
return null;
}
List<URL> roots = new ArrayList<>();
StringTokenizer tok = new StringTokenizer(sbcp, File.pathSeparator);
while (tok.hasMoreTokens()) {
File f = new File(tok.nextToken());
if (!f.exists()) {
continue;
}
URL u;
try {
File normf = FileUtil.normalizeFile(f);
u = Utilities.toURI(normf).toURL();
} catch (MalformedURLException x) {
throw new AssertionError(x);
}
if (FileUtil.isArchiveFile(u)) {
u = FileUtil.getArchiveRoot(u);
}
roots.add(u);
}
return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
}
示例4: findClassesOutputDir
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Find output classes given a compilation unit from project.xml.
*/
private String findClassesOutputDir(Element compilationUnitEl) {
// Look for an appropriate <built-to>.
for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
if (builtTo.getLocalName().equals("built-to")) { // NOI18N
String rawtext = XMLUtil.findText(builtTo);
// Check that it is not an archive.
String evaltext = evaluator.evaluate(rawtext);
if (evaltext != null) {
File dest = helper.resolveFile(evaltext);
URL destU;
try {
destU = Utilities.toURI(dest).toURL();
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
if (!FileUtil.isArchiveFile(destU)) {
// OK, dir, take it.
return rawtext;
}
}
}
}
return null;
}
示例5: createBootPath
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private ClassPath createBootPath () {
try {
String bootPath = System.getProperty ("sun.boot.class.path");
String[] paths = bootPath.split(File.pathSeparator);
List<URL>roots = new ArrayList<URL> (paths.length);
for (String path : paths) {
File f = new File (path);
if (!f.exists()) {
continue;
}
URL url = Utilities.toURI(f).toURL();
if (FileUtil.isArchiveFile(url)) {
url = FileUtil.getArchiveRoot(url);
}
roots.add (url);
}
return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
} catch (MalformedURLException ex) {}
return null;
}
示例6: createBootClassPath
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Creates boot {@link ClassPath} for platform the test is running on,
* it uses the sun.boot.class.path property to find out the boot path roots.
* @return ClassPath
* @throws java.io.IOException when boot path property contains non valid path
*/
public static ClassPath createBootClassPath () throws IOException {
String bootPath = System.getProperty ("sun.boot.class.path");
String[] paths = bootPath.split(File.pathSeparator);
List<URL>roots = new ArrayList<URL> (paths.length);
for (String path : paths) {
File f = new File (path);
if (!f.exists()) {
continue;
}
URL url = Utilities.toURI(f).toURL();
if (FileUtil.isArchiveFile(url)) {
url = FileUtil.getArchiveRoot(url);
}
roots.add (url);
}
return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
}
示例7: getJfxRt
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@CheckForNull
private static PathResourceImplementation getJfxRt(@NonNull final Collection<? extends FileObject> installFolders) {
for (FileObject installFolder : installFolders) {
final FileObject jfxrt = installFolder.getFileObject(JFXRT_PATH);
if (jfxrt != null && FileUtil.isArchiveFile(jfxrt)) {
return ClassPathSupport.createResource(FileUtil.getArchiveRoot(jfxrt.toURL()));
}
}
return null;
}
示例8: translateURL
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static URL translateURL(URL u) {
if (FileUtil.isArchiveFile(u)) {
return FileUtil.getArchiveRoot(u);
} else {
return u;
}
}
示例9: addArchiveToCopy
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* returns archive name or temporarily null cause there is no zip support
* for file protocol
*/
private static String addArchiveToCopy(CreatedModifiedFiles fileSupport, NewLibraryDescriptor.DataModel data, URL originalURL, String pathPrefix) {
String retval = null;
URL archivURL = FileUtil.getArchiveFile(originalURL);
if (archivURL != null && FileUtil.isArchiveFile(archivURL)) {
FileObject archiv = URLMapper.findFileObject(archivURL);
if (archiv == null) {
// #129617: broken library entry, just skip it.
return null;
}
retval = archiv.getNameExt();
fileSupport.add(fileSupport.createFile(pathPrefix + retval, archiv));
} else {
if ("file".equals(originalURL.getProtocol())) {//NOI18N
FileObject folderToZip;
folderToZip = URLMapper.findFileObject(originalURL);
if (folderToZip != null) {
retval = data.getLibraryName() + "-" + folderToZip.getName() + ".zip"; // NOI18N
pathPrefix += retval;
fileSupport.add(new ZipAndCopyOperation(data.getProject(),
folderToZip, pathPrefix));
}
}
}
return retval;
}
示例10: getResources
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public List<? extends PathResourceImplementation> getResources() {
List<FileObject> res;
synchronized (this) {
if (resCache != null) {
return resCache;
}
if (classpathResources == null) {
return Collections.emptyList();
}
res = new ArrayList<>(classpathResources);
}
List<PathResourceImplementation> resources = new ArrayList<>(res.size());
for (FileObject f : res) {
if (FileUtil.isArchiveFile(f)) {
f = FileUtil.getArchiveRoot(f);
}
URL u = URLMapper.findURL(f, URLMapper.EXTERNAL);
if (u != null) {
resources.add(ClassPathSupport.createResource(u));
}
}
synchronized (this) {
if (classpathResources.equals(res)) {
resCache = resources;
}
}
return resources;
}
示例11: fileToURL
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static URL fileToURL (File file, Project project, boolean reportNonExistingFiles, boolean withSlash) {
FileObject fileObject = FileUtil.toFileObject (file);
if (fileObject == null) {
if (reportNonExistingFiles) {
String path = file.getAbsolutePath();
project.log("Have no file for "+path, Project.MSG_WARN);
}
return null;
}
if (FileUtil.isArchiveFile (fileObject)) {
fileObject = FileUtil.getArchiveRoot (fileObject);
if (fileObject == null) {
project.log("Bad archive "+file.getAbsolutePath(), Project.MSG_WARN);
/*
ErrorManager.getDefault().notify(ErrorManager.getDefault().annotate(
new NullPointerException("Bad archive "+file.toString()),
NbBundle.getMessage(JPDAStart.class, "MSG_WrongArchive", file.getAbsolutePath())));
*/
return null;
}
}
if (withSlash) {
return FileUtil.urlForArchiveOrDir(file);
} else {
return fileObject.toURL ();
}
}
示例12: addArchiveFiles
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public boolean addArchiveFiles(final String classPathId, FileObject[] archiveFiles, final String projectXMLElementName) throws IOException {
for (int i = 0; i < archiveFiles.length; i++) {
FileObject archiveFile = archiveFiles[i];
if (FileUtil.isArchiveFile(archiveFile)) {
archiveFiles[i] = FileUtil.getArchiveRoot(archiveFile);
}
}
URI[] archiveFileURIs = new URI[archiveFiles.length];
for (int i = 0; i < archiveFiles.length; i++) {
archiveFileURIs[i] = archiveFiles[i].toURI();
}
return this.delegate.handleRoots(archiveFileURIs, classPathId, projectXMLElementName, ClassPathModifier.ADD);
}
示例13: getRoots
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public synchronized URL[] getRoots() {
URL[] toRet;
checkCurrentProject();
Project prj = currentProject;
if (prj != null) {
toRet = new URL[0];
} else {
URL root = FileUtil.isArchiveFile(binary) ? FileUtil.getArchiveRoot(binary) : binary;
File[] f = SourceJavadocByHash.find(root, true);
if (f != null) {
List<URL> accum = new ArrayList<URL>();
for (File ff : f) {
URL[] url = getJavadocJarRoot(ff);
if (url != null) {
accum.addAll(Arrays.asList(url));
}
}
toRet = accum.toArray(new URL[0]);
} else if (javadocJarFile != null && javadocJarFile.exists()) {
toRet = getJavadocJarRoot(javadocJarFile);
} else {
toRet = checkShadedMultiJars();
}
}
if (!Arrays.equals(cached, toRet)) {
//how to figure otherwise that something changed, possibly multiple people hold the result instance
// and one asks the roots, later we get event from outside, but then the cached value already updated..
RP.post(new Runnable() {
@Override
public void run() {
support.fireChange();
}
});
}
cached = toRet;
return toRet;
}
示例14: getJavadocJarRoot
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private URL[] getJavadocJarRoot(File file) {
try {
if (file.exists()) {
FileObject fo = FileUtil.toFileObject(file);
if (!FileUtil.isArchiveFile(fo)) {
//#124175 ignore any jar files that are not jar files (like when downloaded file is actually an error html page).
Logger.getLogger(RepositoryForBinaryQueryImpl.class.getName()).log(Level.INFO, "javadoc in repository is not really a JAR: {0}", file);
return new URL[0];
}
//try detecting the source path root, in case the source jar has the sources not in root.
Date date = (Date) fo.getAttribute(ATTR_STAMP);
String path = (String) fo.getAttribute(ATTR_PATH);
if (date == null || fo.lastModified().after(date)) {
path = checkPath(FileUtil.getArchiveRoot(fo), fo);
}
URL[] url;
if (path != null) {
url = new URL[1];
URL root = FileUtil.getArchiveRoot(Utilities.toURI(file).toURL());
if (!path.endsWith("/")) { //NOI18N
path = path + "/"; //NOI18N
}
url[0] = new URL(root, path);
} else {
url = new URL[1];
url[0] = FileUtil.getArchiveRoot(Utilities.toURI(file).toURL());
}
return url;
}
} catch (MalformedURLException exc) {
ErrorManager.getDefault().notify(exc);
}
return new URL[0];
}
示例15: accept
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public boolean accept(File f) {
if (f.isDirectory())
return true;
try {
return FileUtil.isArchiveFile(Utilities.toURI(f).toURL());
} catch (MalformedURLException mue) {
ErrorManager.getDefault().notify(mue);
return false;
}
}