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


Java File.equals方法代码示例

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


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

示例1: validateInstallLocked

import java.io.File; //导入方法依赖的package包/类
private void validateInstallLocked() throws PackageManagerException {
    mResolvedBaseFile = null;
    mResolvedStagedFiles.clear();
    File[] addedFiles = this.mResolvedStageDir.listFiles();
    if (addedFiles == null || addedFiles.length == 0) {
        throw new PackageManagerException(INSTALL_FAILED_INVALID_APK, "No packages staged");
    }
    for (File addedFile : addedFiles) {
        if (!addedFile.isDirectory()) {
            final String targetName = "base.apk";
            final File targetFile = new File(mResolvedStageDir, targetName);
            if (!addedFile.equals(targetFile)) {
                addedFile.renameTo(targetFile);
            }
            mResolvedBaseFile = targetFile;
            mResolvedStagedFiles.add(targetFile);
        }
    }
    if (mResolvedBaseFile == null) {
        throw new PackageManagerException(INSTALL_FAILED_INVALID_APK,
                "Full install must include a base package");
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:24,代码来源:PackageInstallerSession.java

示例2: insertSourceMarkers

import java.io.File; //导入方法依赖的package包/类
private static File insertSourceMarkers(@NonNull Node node, @Nullable File currentFile) {
    for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        Node child = node.getChildNodes().item(i);
        short nodeType = child.getNodeType();
        if (nodeType == Node.ELEMENT_NODE
                || nodeType == Node.COMMENT_NODE
                || nodeType == Node.DOCUMENT_NODE
                || nodeType == Node.CDATA_SECTION_NODE) {
            File file = MergerXmlUtils.getFileFor(child);
            if (file != null && !file.equals(currentFile)) {
                i += insertSourceMarker(node, child, file, false);
                currentFile = file;
            }

            currentFile = insertSourceMarkers(child, currentFile);
        }
    }

    Node lastElement = node.getLastChild();
    while (lastElement != null && lastElement.getNodeType() == Node.TEXT_NODE) {
        lastElement = lastElement.getPreviousSibling();
    }
    if (lastElement != null && lastElement.getNodeType() == Node.ELEMENT_NODE) {
        File parentFile = MergerXmlUtils.getFileFor(node);
        File lastFile = MergerXmlUtils.getFileFor(lastElement);
        if (lastFile != null && parentFile != null && !parentFile.equals(lastFile)) {
            insertSourceMarker(node, lastElement, parentFile, true);
            currentFile = parentFile;
        }
    }

    return currentFile;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:34,代码来源:ManifestMerger.java

示例3: getAbsFileName

import java.io.File; //导入方法依赖的package包/类
private static String getAbsFileName(String baseDir, File realFileName) {
    File real = realFileName;
    File base = new File(baseDir);
    String ret = real.getName();
    while (true) {
        real = real.getParentFile();
        if (real == null) {
            break;
        }
        if (real.equals(base)) {
            break;
        } else {
            ret = real.getName() + "/" + ret;
        }
    }
    return ret;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:18,代码来源:ZipUtils.java

示例4: findApkMatchingHash

import java.io.File; //导入方法依赖的package包/类
/**
 * There could be multiple apks with the same hash, provided by different repositories.
 * This method looks for all matching records in the database. It then asks each of these
 * {@link Apk} instances where they expect to be downloaded. If they expect to be downloaded
 * to {@param apkPath} then that instance is returned.
 *
 * If no files have a matching hash, or only those which don't belong to the correct repo, then
 * this will return null.
 */
@Nullable
private Apk findApkMatchingHash(File apkPath) {

    // NOTE: This presumes SHA256 is the only supported hash. It seems like that is an assumption
    // in more than one place in the F-Droid client. If this becomes a problem in the future, we
    // can query the Apk table for `SELECT DISTINCT hashType FROM fdroid_apk` and then we can just
    // try each of the hash types that have been specified in the metadata. Seems a bit overkill
    // at the time of writing though.
    String hash = Utils.getBinaryHash(apkPath, "sha256");

    List<Apk> apksMatchingHash = ApkProvider.Helper.findApksByHash(this, hash);
    Utils.debugLog(TAG, "Found " + apksMatchingHash.size() + " apk(s) matching the hash " + hash);

    for (Apk apk : apksMatchingHash) {
        if (apkPath.equals(ApkCache.getApkDownloadPath(this, Uri.parse(apk.getUrl())))) {
            return apk;
        }
    }

    return null;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:31,代码来源:AppUpdateStatusService.java

示例5: getDestinationFile

import java.io.File; //导入方法依赖的package包/类
/**
 * Calculates the destination file.
 *
 * @param resource the source file
 * @return the destination file's parent directory
 */
private File getDestinationFile( File resource )
{
    File parent = resource.getParentFile();
    Deque<String> fileComponentStack = new ArrayDeque<>();
    fileComponentStack.push( resource.getName() );

    while ( parent != null )
    {
        if ( "schema".equals( parent.getName() ) )
        {
            // All LDIF files besides the schema.ldif are under the 
            // schema/schema base path. So we need to add one more 
            // schema component to all LDIF files minus this schema.ldif
            fileComponentStack.push( "schema" );

            return assembleDestinationFile( fileComponentStack );
        }

        fileComponentStack.push( parent.getName() );

        if ( parent.equals( parent.getParentFile() ) || parent.getParentFile() == null )
        {
            throw new IllegalStateException( I18n.err( I18n.ERR_08005 ) );
        }

        parent = parent.getParentFile();
    }

    throw new IllegalStateException( I18n.err( I18n.ERR_08006 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:DefaultSchemaLdifExtractor.java

示例6: getFiles

import java.io.File; //导入方法依赖的package包/类
public File[] getFiles(File dir, boolean hide_hidden) {
    if (dir.equals(bug6698013.root)) {
        return new File[]{bug6698013.rootFile, bug6698013.subdir};
    }

    if (dir.equals(bug6698013.subdir)) {
        return new File[]{bug6698013.subdirFile};
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:bug6698013.java

示例7: getRelativePath

import java.io.File; //导入方法依赖的package包/类
public static String getRelativePath (File repo, final File file) {
    StringBuilder relativePath = new StringBuilder(""); //NOI18N
    File parent = file;
    if (!parent.equals(repo)) {
        while (parent != null && !parent.equals(repo)) {
            relativePath.insert(0, "/").insert(0, parent.getName()); //NOI18N
            parent = parent.getParentFile();
        }
        if (parent == null) {
            throw new IllegalArgumentException(file.getAbsolutePath() + " is not under " + repo.getAbsolutePath());
        }
        relativePath.deleteCharAt(relativePath.length() - 1);
    }
    return relativePath.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:GitUtils.java

示例8: getColumnNames

import java.io.File; //导入方法依赖的package包/类
private Object[] getColumnNames() {
    MyTreeNode selectedTreeNode = FileExplorer.selectedTreeNode;

    if (selectedTreeNode == null) {
        return null;
    }

    File selectedDir = (File) selectedTreeNode.getUserObject();

    if (selectedDir.equals(new File(FileExplorer.MY_COMPUTER_FOLDER_PATH))) {
        return columnNamesMyComputer;
    } else {
        return columnNamesFile;
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:MyTableModel.java

示例9: push

import java.io.File; //导入方法依赖的package包/类
@Override public void push(File local, File remote) {
    if (remote.equals(local)) {
        return;
    }
    // if the user dir exists, cp would copy the files to the wrong place
    if (remote.exists()) {
        throw new IllegalStateException();
    }
    new Command(run.log, "cp", "-r", local.toString(), remote.toString()).execute();
}
 
开发者ID:dryganets,项目名称:vogar,代码行数:11,代码来源:LocalTarget.java

示例10: run

import java.io.File; //导入方法依赖的package包/类
public void run() {
	//myLog.l(Log.INFO, "RMD executing");
	String param = getParameter(input);
	File toRemove;
	String errString = null;
	mainblock: {
		if(param.length() < 1) {
			errString = "550 Invalid argument\r\n";
			break mainblock;
		}
		toRemove = inputPathToChrootedFile(sessionThread.getWorkingDir(), param);
		if(violatesChroot(toRemove)) {
			errString = "550 Invalid name or chroot violation\r\n";
			break mainblock;
		}
		if(!toRemove.isDirectory()) {
			errString = "550 Can't RMD a non-directory\r\n";
			break mainblock;
		}
		if(toRemove.equals(new File("/"))) {
			errString = "550 Won't RMD the root directory\r\n";
			break mainblock;
		}
		if(!recursiveDelete(toRemove)) {
			errString = "550 Deletion error, possibly incomplete\r\n";
			break mainblock;
		}
	}
	if(errString != null) {
		sessionThread.writeString(errString);
		//myLog.l(Log.INFO, "RMD failed: " + errString.trim());
	} else {
		sessionThread.writeString("250 Removed directory\r\n");
	}
	//myLog.l(Log.DEBUG, "RMD finished");
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:37,代码来源:CmdRMD.java

示例11: restore

import java.io.File; //导入方法依赖的package包/类
/**
 * Move a current but rotated log file back to the unrotated one. Needed if
 * date stamp inclusion is deferred to rotation time.
 */
private void restore() {
	File newLogFile = getLogFile(false);
	File rotatedLogFile = getLogFile(true);
	if (rotatedLogFile.exists() && !newLogFile.exists() && !rotatedLogFile.equals(newLogFile)) {
		try {
			if (!rotatedLogFile.renameTo(newLogFile)) {
				log.error(sm.getString("accessLogValve.renameFail", rotatedLogFile, newLogFile));
			}
		} catch (Throwable e) {
			ExceptionUtils.handleThrowable(e);
			log.error(sm.getString("accessLogValve.renameFail", rotatedLogFile, newLogFile), e);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:AccessLogValve.java

示例12: checkRoot

import java.io.File; //导入方法依赖的package包/类
private Res checkRoot(File root, File source, File test) {
    if (source != null && source.equals(root)) {
        return new Res(false, project.getLookup().lookup(NbMavenProjectImpl.class));
    }
    if (test != null && test.equals(root)) {
        return new Res(true, project.getLookup().lookup(NbMavenProjectImpl.class));
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:MavenBinaryForSourceQueryImpl.java

示例13: getPathToRoot

import java.io.File; //导入方法依赖的package包/类
public String getPathToRoot(File sourceFile) {
	File rootPath = new File(contentPath);
	File parentPath = sourceFile.getParentFile();
	int parentCount = 0;
	while (!parentPath.equals(rootPath)) {
		parentPath = parentPath.getParentFile();
		parentCount++;
	}
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < parentCount; i++) {
		sb.append("../");
	}
	return sb.toString();
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:15,代码来源:Crawler.java

示例14: acceptDir

import java.io.File; //导入方法依赖的package包/类
private boolean acceptDir(File pathToDir) {
	String absolute = RewriteUtils.makeUniform(pathToDir.getAbsolutePath());
	for (String exclude : excludeDirs) {
		if (absolute.endsWith(exclude)) return false;
	}
	if (subdirs) return true;
	return pathToDir.equals(dir);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:9,代码来源:IncludeDir.java

示例15: isRoot

import java.io.File; //导入方法依赖的package包/类
@Override
public boolean isRoot(File file) {
    for (File root : roots) {
        if (root.equals(file)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:FXMLTemplateWizardIterator.java


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