Example usage for java.io File getAbsolutePath

List of usage examples for java.io File getAbsolutePath

Introduction

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

Prototype

public String getAbsolutePath() 

Source Link

Document

Returns the absolute pathname string of this abstract pathname.

Usage

From source file:Main.java

public static String getInstancesFolder(String appName, String tableId) {
    String path;//from   w  w  w .j  a v  a2 s  .  c o m
    path = getTablesFolder(appName, tableId) + File.separator + INSTANCES_FOLDER_NAME;

    File f = new File(path);
    f.mkdirs();
    return f.getAbsolutePath();
}

From source file:Main.java

/***********************************************************************/
public static String locateFile(String fileLocation, String backupPaths[]) throws Exception {
    String[] newArray = new String[backupPaths.length + 1];
    System.arraycopy(backupPaths, 0, newArray, 1, backupPaths.length);
    newArray[0] = ".";
    backupPaths = newArray;/*  ww w  .  j  a  va  2 s  .c o  m*/
    for (int i = 0; i < backupPaths.length; i++) {
        String tfileLocation = backupPaths[i] + File.separator + fileLocation;
        File file = new File(tfileLocation);
        if (file.exists()) {
            return file.getAbsolutePath();
        }
    }
    throw new Error(String.format("Couldn't find '%s' from locations %s with current directory '%s'",
            fileLocation, Arrays.asList(backupPaths), new File(".").getAbsolutePath()));
}

From source file:Main.java

/**
 * Try to cache parsed Templates, but check for changes on disk
 * @param src/* w  w w  . j  a  v a 2s . c  om*/
 * @return
 */
public static Templates getTemplates(File src) throws TransformerException {
    String key = src.getAbsolutePath();
    if (XSL_MODIFIED.containsKey(key)) {
        // check to see if it has changed
        if (src.lastModified() <= XSL_MODIFIED.get(key).longValue()) {
            return TEMPLATES_CACHE.get(key);
        }
    }
    Templates template = getTransformerFactory().newTemplates(new StreamSource(src));
    TEMPLATES_CACHE.put(key, template);
    XSL_MODIFIED.put(key, src.lastModified());
    return template;
}

From source file:Main.java

public static String getDir(Context context, String path) {
    //      File dir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    path = dir.getAbsolutePath() + "/" + path;
    return path;/*from   www.  j a v  a 2s .  c om*/
}

From source file:Main.java

public static String getStoragePath() {
    if (!isCardExist())
        return null;
    File path = Environment.getExternalStorageDirectory();
    if (path != null && !TextUtils.isEmpty(path.getAbsolutePath())) {
        return path.getAbsolutePath();
    } else {//  w w  w.  j a v  a 2  s .c o  m
        return null;
    }
}

From source file:com.stratio.mojo.scala.crossbuild.FileRewriter.java

private static File getBackupFileName(final File origFile) throws IOException {
    return new File(origFile.getAbsolutePath() + BKP_SUFFIX);
}

From source file:com.ansorgit.plugins.bash.util.SystemPathUtil.java

@Nullable
public static String findExecutable(@NotNull String commandName, String path) {
    String fullPath = path + File.separatorChar + commandName;
    File command = new File(fullPath);
    return command.exists() ? command.getAbsolutePath() : null;
}

From source file:Main.java

public static String getExternalStorage() {
    String extSdCardStr = System.getenv("SECONDARY_STORAGE");
    if (extSdCardStr != null) {
        File extSdCardFile = new File(extSdCardStr);
        if (extSdCardFile.isDirectory())
            return extSdCardFile.getAbsolutePath();
    }/*  w w  w  .  j a v  a2s  .  co  m*/

    return "";
}

From source file:Main.java

public static String getFileRoot(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File external = context.getExternalFilesDir(null);
        if (external != null) {
            return external.getAbsolutePath();
        }/*from ww w . j a  v  a2 s .c o m*/
    }
    return context.getFilesDir().getAbsolutePath();
}

From source file:de.tudarmstadt.ukp.dkpro.tc.ml.modelpersist.ModelPersistUtil.java

private static boolean isExistingFilePath(File tcModelLocation, String name) {

    return new File(tcModelLocation.getAbsolutePath() + "/" + name).exists();
}