Example usage for java.io File getPath

List of usage examples for java.io File getPath

Introduction

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

Prototype

public String getPath() 

Source Link

Document

Converts this abstract pathname into a pathname string.

Usage

From source file:com.firewallid.util.FIFile.java

public static void copyFolderToWorkingDirectory(Class clazz, String folderPath, boolean override)
        throws IOException, URISyntaxException {
    File folder = new File(folderPath);
    File workingDirectory = getWorkingDirectory(clazz);
    if (override || !(new File(workingDirectory.getPath() + "/" + folder.getName()).exists())) {
        FileUtils.copyDirectoryToDirectory(folder, workingDirectory);
    }/*from   w w w.j av  a  2 s  .  c  om*/
    LOG.info("Copy folder to working directory: " + folderPath + " -> " + workingDirectory.getPath());
}

From source file:com.itbeyond.common.EOTrackMe.java

public static File getLogFile() {
    File gpxFolder = new File(Environment.getExternalStorageDirectory(), "EOLogger");
    return new File(gpxFolder.getPath(), "Sender.log");
}

From source file:net.krotscheck.util.ResourceUtil.java

/**
 * Convert a resource path to an absolute file path.
 *
 * @param resourcePath The resource-relative path to resolve.
 * @return The absolute path to this resource.
 *///from  w  w  w .j  a  v a2  s  .c o  m
public static String getPathForResource(final String resourcePath) {
    URL path = ResourceUtil.class.getResource(resourcePath);
    if (path == null) {
        path = ResourceUtil.class.getResource("/");
        File tmpFile = new File(path.getPath(), resourcePath);
        return tmpFile.getPath();
    }

    return path.getPath();
}

From source file:Main.java

/**
 * Get the list of xml files in the bookmark export folder.
 * @return The list of xml files in the bookmark export folder.
 *//*  ww w.  ja  v a2s  . c  om*/
public static List<String> getExportedBookmarksFileList() {
    List<String> result = new ArrayList<String>();

    File folder = getBookmarksExportFolder();

    if (folder != null) {

        FileFilter filter = new FileFilter() {

            @Override
            public boolean accept(File pathname) {
                if ((pathname.isFile()) && (pathname.getPath().endsWith(".xml"))) {
                    return true;
                }
                return false;
            }
        };

        File[] files = folder.listFiles(filter);

        for (File file : files) {
            result.add(file.getName());
        }
    }

    Collections.sort(result, new Comparator<String>() {

        @Override
        public int compare(String arg0, String arg1) {
            return arg1.compareTo(arg0);
        }
    });

    return result;
}

From source file:net.orpiske.ssps.common.repository.ProviderFactory.java

private static boolean isRepository(final File repositoryPath, final String metadataDir) {
    String metadataSubDir = repositoryPath.getPath() + File.separator + metadataDir;
    File dir = new File(metadataSubDir);

    if (dir.exists()) {
        return true;
    }/*from   ww w  .  jav  a2s  . c  o m*/

    return false;
}

From source file:com.navercorp.pinpoint.bootstrap.agentdir.AgentDirBaseClassPathResolverTest.java

private static String getClassLocation(Class<?> clazz) {
    URL location = CodeSourceUtils.getCodeLocation(clazz);
    logger.debug("codeSource.getCodeLocation:{}", location);
    File file = FileUtils.toFile(location);
    return file.getPath();
}

From source file:com.navercorp.pinpoint.bootstrap.AgentDirBaseClassPathResolverTest.java

private static String getClassLocation(Class<?> clazz) {
    CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
    URL location = codeSource.getLocation();
    logger.debug("codeSource.getLocation:{}", location);
    File file = FileUtils.toFile(location);
    return file.getPath();
}

From source file:com.ColonelHedgehog.Sites.Services.URLServices.DLC.java

public static boolean installPackage(File f) {
    if (f.isDirectory()) {
        if (new File(f.getPath() + "/install.cnp").exists()) {
            parseCrossNetworkParseable(new File(f.getPath() + "/install.cnp"));
            return true;
        } else {/*from  w  ww  . j a  v  a 2 s  .com*/
            System.out.println(
                    "[CS | CNP] Could not parse " + f.getPath() + "/install.cnp" + ". Does not exist.");
        }
    } else {
        System.out.println("[CS | CNP] Could not load " + f.getName() + ". It is a file.");
    }
    return false;
}

From source file:com.flysystem.core.adapter.local.FileCommands.java

private static void validateIsFileAndExists(File file) throws FileNotFoundException {
    if (!file.exists() || !file.isFile())
        throw new FileNotFoundException(file.getPath());
}

From source file:FileUtil.java

/**
 * Zip up a directory path//w  w w. j  a  v  a 2s . co m
 * @param directory
 * @param zos
 * @param path
 * @throws IOException
 */
public static void zipDir(String directory, ZipOutputStream zos, String path) throws IOException {
    File zipDir = new File(directory);
    // get a listing of the directory content
    String[] dirList = zipDir.list();
    byte[] readBuffer = new byte[2156];
    int bytesIn = 0;
    // loop through dirList, and zip the files
    for (int i = 0; i < dirList.length; i++) {
        File f = new File(zipDir, dirList[i]);
        if (f.isDirectory()) {
            String filePath = f.getPath();
            zipDir(filePath, zos, path + f.getName() + "/");
            continue;
        }
        FileInputStream fis = new FileInputStream(f);
        try {
            ZipEntry anEntry = new ZipEntry(path + f.getName());
            zos.putNextEntry(anEntry);
            bytesIn = fis.read(readBuffer);
            while (bytesIn != -1) {
                zos.write(readBuffer, 0, bytesIn);
                bytesIn = fis.read(readBuffer);
            }
        } finally {
            fis.close();
        }
    }
}