Example usage for java.io File equals

List of usage examples for java.io File equals

Introduction

In this page you can find the example usage for java.io File equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Tests this abstract pathname for equality with the given object.

Usage

From source file:guru.nidi.ramlproxy.core.MockServlet.java

private File findFileOrParent(File targetDir, String name, String method) {
    File file = findFile(targetDir, name, method);
    while (file == null && targetDir != null && !targetDir.equals(mockDir.getParentFile())) {
        file = findFile(targetDir, "RESPONSE", method);
        targetDir = targetDir.getParentFile();
    }/*from  w  ww  . j a  va2s  .c o  m*/
    return file;
}

From source file:org.dbgl.util.FileUtils.java

public static File makeRelativeTo(final File file, final File basePath) {
    if (!file.isAbsolute()) {
        return file;
    }/*ww w.  j  a v  a2 s . co m*/
    if (file.equals(basePath)) {
        return new File(".");
    }
    File remainder = new File(file.getName());
    File parent = file.getParentFile();
    while (parent != null) {
        if (parent.equals(basePath)) {
            return remainder;
        }
        remainder = new File(parent.getName(), remainder.getPath());
        parent = parent.getParentFile();
    }
    return file;
}

From source file:org.dbgl.util.FileUtils.java

public static boolean areRelated(final File parent, final File child) {
    File remainder = child.getParentFile();
    while (remainder != null) {
        if (parent.equals(remainder)) {
            return true;
        }/*w ww .j av a  2 s  .  c  o m*/
        remainder = remainder.getParentFile();
    }
    return false;
}

From source file:com.greenpepper.report.FileReportGenerator.java

/** {@inheritDoc} */
public void closeReport(Report report) throws IOException, URISyntaxException {
    FileWriter out = null;/*from w ww.j  a  v  a2  s.  co m*/
    try {
        File reportFile = new File(reportsDirectory, outputNameOf(report));
        String documentUri = report.getDocumentUri();
        if (documentUri != null) {
            if (reportFile.equals(new File(new URI(documentUri)))) {
                reportFile = new File(reportFile.getAbsolutePath() + ".out");
            }
        }
        IOUtil.createDirectoryTree(reportFile.getParentFile());
        StringWriter strOut = new StringWriter();
        report.printTo(strOut);
        strOut.flush();
        out = new FileWriter(reportFile);
        String reportString = strOut.toString();
        LOGGER.trace("Final Report to be written :\n {}", reportString);
        IOUtils.write(reportString, out);
        out.flush();
    } finally {
        IOUtil.closeQuietly(out);
    }
}

From source file:org.commonjava.maven.ext.manip.CliTest.java

@Test
public void checkTargetMatches() throws Exception {
    Cli c = new Cli();
    File pom1 = new File("/tmp/foobar");
    File settings1 = new File("/tmp/foobarsettings");

    executeMethod(c, "createSession", new Object[] { pom1, settings1 });

    assertTrue("Session file should match",
            pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom()));
}

From source file:org.commonjava.maven.ext.cli.CliTest.java

@Test
public void checkTargetDefaultMatches() throws Exception {
    Cli c = new Cli();

    executeMethod(c, "run", new Object[] { new String[] {} });

    ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
    File defaultTarget = (File) FieldUtils.readField(c, "target", true);

    assertTrue("Session file should match", defaultTarget.equals(session.getPom()));
}

From source file:com.jparkie.aizoban.presenters.SettingsPresenterImpl.java

@Override
public void initializeDownloadDirectory() {
    ListPreference downloadPreference = mSettingsMapper.getDownloadStoragePreference();
    if (downloadPreference != null) {
        String[] downloadDirectories = DiskUtils.getStorageDirectories();

        downloadPreference.setEntries(downloadDirectories);
        downloadPreference.setEntryValues(downloadDirectories);

        downloadPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override/* w w  w . ja  va  2s  .  c o  m*/
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                String downloadDirectory = (String) newValue;
                if (downloadDirectory != null) {
                    File actualDirectory = new File(downloadDirectory);

                    if (!actualDirectory.equals(AizobanApplication.getInstance().getFilesDir())) {
                        boolean isWritable = actualDirectory.mkdirs();

                        try {
                            File tempFile = File.createTempFile("tempTestDirectory", "0", actualDirectory);
                            tempFile.delete();

                            isWritable = true;
                        } catch (IOException e) {
                            isWritable = false;
                        }

                        if (!isWritable) {
                            mSettingsView.toastExternalStorageError();

                            return false;
                        }
                    }
                }

                return true;
            }
        });
    }
}

From source file:org.dbflute.helper.io.compress.DfZipArchiver.java

protected boolean isTopDir(File topDir, File targetFile) {
    return targetFile.isDirectory() && topDir.equals(targetFile);
}

From source file:org.dbflute.helper.io.compress.DfZipArchiver.java

protected boolean isSubDir(File topDir, File targetFile) {
    return targetFile.isDirectory() && !topDir.equals(targetFile);
}

From source file:org.kse.gui.actions.KeyStoreExplorerAction.java

/**
 * Is the supplied KeyStore file open?//from  w w  w. j a  va 2s. co  m
 *
 * @param keyStoreFile
 *            KeyStore file
 * @return True if it is
 */
protected boolean isKeyStoreFileOpen(File keyStoreFile) {
    KeyStoreHistory[] histories = kseFrame.getKeyStoreHistories();

    for (int i = 0; i < histories.length; i++) {
        File f = histories[i].getFile();

        if (f != null && f.equals(keyStoreFile)) {
            return true;
        }
    }

    return false;
}