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:org.psikeds.common.config.ConfigDirectoryHelper.java

/**
 * Look for a configuration file within the configuration directory.
 * /* w  ww. j a  v  a  2s  . c om*/
 * @param file
 *          File object representing the configuration file
 * @return File object if the config file exists and is readable;
 *         null otherwise
 */
static File resolveConfigFile(final File file) {
    return resolveConfigFile(file.getPath());
}

From source file:ActivejdbcTest.java

@BeforeClass
public static void setup() throws Exception {
    File webAppPath = new File("files");
    micro = new Micro(webAppPath.getPath(), null, "../../lib");
    Assert.assertNotNull(micro);/*from  w w  w .ja v a 2  s.  c o m*/
    SITE = micro.getSite();
    Assert.assertNotNull(SITE);
    SITE.setMicroEnv(Globals.TEST);
    // overwrite the ExtensionManager
    // todo: design a nicer support for integrating with the extensions testing units
    String extensionsFolder = System.getenv("EXTENSIONS_FOLDER");
    Assert.assertNotNull("Must specify the extensions folder. Missing.", extensionsFolder);
    File extensionConfigFile = new File(extensionsFolder + EXTENSION_NAME + ".yml");
    SITE.setExtensionsManager(new ExtensionsManager(SITE, new File[] { extensionConfigFile }));
    SITE.getExtensionsManager().require(EXTENSION_NAME);

    Assert.assertNotNull("Micro 'SITE' initialization failed", micro.getSite().getWebInfPath());
    Assert.assertTrue("Micro is not pointing to the correct test web app",
            SITE.getWebInfPath().getAbsolutePath().contains("files/WEB-INF"));
    Assert.assertTrue("Micro test web app is not properly defined", SITE.getWebInfPath().exists());
}

From source file:Main.java

public static void clearCache(Context context) {

    File cache = context.getCacheDir();
    String[] files = cache.list();
    for (String file : files) {
        File data = new File(cache.getPath() + "/" + file);
        data.delete();//  w  w w  .j av a 2 s . c  o m
    }
}

From source file:io.fabric8.maven.core.util.ResourceFileType.java

public static ResourceFileType fromFile(File file) {
    String ext = FilenameUtils.getExtension(file.getPath());
    if (StringUtils.isNotBlank(ext)) {
        return fromExtension(ext);
    } else {/*from w  w w  .ja  v  a  2 s .c  o m*/
        throw new IllegalArgumentException(
                String.format("Unsupported extension '%s' for file %s. Must be one of %s", ext, file,
                        Arrays.asList(values())));
    }
}

From source file:Main.java

public static void copyDir(String src, String dst) {
    try {// w w  w.j a v  a  2  s.c o  m
        File fileSrc = new File(src);
        if (!fileSrc.exists()) {
            return;
        }
        File[] filelist = fileSrc.listFiles();
        File fileDst = new File(dst);
        if (!fileDst.exists()) {
            fileDst.mkdirs();
        }
        for (File f : filelist) {
            if (f.isDirectory()) {
                copyDir(f.getPath() + "/", dst + f.getName() + "/");
            } else {
                copyFile(f.getPath(), dst + f.getName());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.di.bi.nextgen.installattribution.searchcountrycode.SearchCountryCode.java

public static org.json.JSONArray ReadJson() throws FileNotFoundException, IOException, ParseException {
    JSONParser parser = new JSONParser();
    File configFile = new File("test.json");
    String fileConfigurationContent = readFile(configFile.getPath());
    org.json.JSONArray jsonObj = new org.json.JSONArray(fileConfigurationContent);
    System.out.println("------------------------" + jsonObj.toString());
    Map<String, Object> map = new HashMap();
    return jsonObj;
}

From source file:Main.java

public static String getDownAudioPath(Context context, String url) {
    String fileName = url.substring(url.lastIndexOf("/") + 1);
    File mediaStorageDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_RINGTONES),
            AudioFolderName);/*w ww.  j  a  v a2s.c o  m*/

    return mediaStorageDir.getPath() + File.separator + fileName;
}

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.
 *///from   w  w  w .jav  a  2  s  . c  o m
public static List<String> getExportedBookmarksFileList() {
    List<String> result = new ArrayList<String>();

    File folder = Environment.getExternalStorageDirectory();

    if (folder != null) {

        FileFilter filter = new FileFilter() {

            @Override
            public boolean accept(File pathname) {
                if ((pathname.isFile()) && (pathname.getPath().toLowerCase(Locale.US).endsWith(".xml")
                        || pathname.getPath().toLowerCase(Locale.US).endsWith(".json"))) {
                    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:Main.java

public static long getSdCardAvailableSize() {
    File sdcardDir = android.os.Environment.getExternalStorageDirectory();
    StatFs sf = null;/*  w ww . j av a 2 s.c o m*/
    try {
        sf = new StatFs(sdcardDir.getPath());
    } catch (Exception e) {
        return 0;
    }
    long blockSize = sf.getBlockSize();
    long availCount = sf.getAvailableBlocks();
    return availCount * blockSize;
}

From source file:ConsoleUtils.java

public static Process exec(String exePath, List files, boolean stop) throws InterruptedException, IOException {
    List filePaths = new ArrayList();
    filePaths.add(exePath);/*from   w  ww .  j  a v  a  2  s.c o m*/
    for (int i = 0; i < files.size(); i++) {
        File file = (File) files.get(i);
        filePaths.add(file.getPath());
    }
    String command[] = (String[]) filePaths.toArray(new String[filePaths.size()]);
    return exec(command, stop);
}