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:de.betterform.cache.CacheManager.java

/**
 *
 * @param file cache key/*  w ww.  ja  v  a2  s  . co  m*/
 * @param  object W3C DOM Docuemt (Cache value)
 */
public static void putIntoFileCache(File file, Object object) {
    xfFileCache.put(new Element(file.getAbsolutePath() + file.lastModified(), object));
}

From source file:io.github.benas.jql.Utils.java

public static String getDatabasePath(File directory) {
    String fileSeparator = getProperty("file.separator");
    return directory.getAbsolutePath() + fileSeparator + "jql.db";
}

From source file:be.hikage.maven.plugin.xmlmerge.utils.PathUtils.java

public static String getRelativePath(File children, File base) {

    String normalizedTargetPath = FilenameUtils.normalizeNoEndSeparator(children.getAbsolutePath());
    String normalizedBasePath = FilenameUtils.normalizeNoEndSeparator(base.getAbsolutePath());

    System.out.println(normalizedTargetPath);
    System.out.println(normalizedBasePath);

    return normalizedTargetPath.substring(normalizedBasePath.length());

}

From source file:com.splout.db.common.CompressorUtil.java

public static String getRelativePath(File file, File folder) {
    String filePath = file.getAbsolutePath();
    String folderPath = folder.getAbsolutePath();
    if (filePath.startsWith(folderPath)) {
        return filePath.substring(folderPath.length() + 1);
    } else {/* w w w.ja va2 s  .  c o m*/
        return null;
    }
}

From source file:Main.java

public static int getCameraPhotoOrientation(Context context, Uri imageUri, String imagePath) {
    int rotate = 0;
    try {/*from  w  w w  . j  a v  a  2  s .co  m*/
        context.getContentResolver().notifyChange(imageUri, null);
        File imageFile = new File(imagePath);

        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            rotate = 270;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            rotate = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            rotate = 90;
            break;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return rotate;
}

From source file:Main.java

public static void deleteTempFiles() throws IOException {
    File file = createTempFile("test", "test");
    String folder = getDirectoryForFile(file.getAbsolutePath());
    String[] list = new File(folder).list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.startsWith("ohfu-");
        }/*from   w w  w . j  a  v a  2s .c om*/
    });
    if (list != null) {
        for (String n : list) {
            new File(path(folder, n)).delete();
        }
    }
}

From source file:Main.java

/**
 * By default File#delete fails for non-empty directories, it works like "rm". We need something
 * a little more brutual - this does the equivalent of "rm -r"
 *
 * @param path Root File Path//  ww w .j  a v  a 2s .  c  om
 * @return true iff the file and all sub files/directories have been removed
 */
public static boolean deleteRecursive(File path) throws FileNotFoundException {
    if (!path.exists()) {
        throw new FileNotFoundException(path.getAbsolutePath());
    }
    boolean ret = true;
    if (path.isDirectory()) {
        for (File f : path.listFiles()) {
            ret = ret && deleteRecursive(f);
        }
    }
    return ret && path.delete();
}

From source file:Main.java

public static void playRecordAction(File audiofile) throws Exception {
    MediaPlayer mp = new MediaPlayer();
    FileInputStream fis = new FileInputStream(audiofile.getAbsolutePath());
    mp.setDataSource(fis.getFD());/*  w  w  w. java  2 s  .c  o m*/
    mp.prepare();
    fis.close();
    mp.start();
}

From source file:Main.java

public static int getOrientation(final String imagePath) {
    int rotate = 0;
    try {/*from   w  w w .  j av  a2s.com*/
        File imageFile = new File(imagePath);
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            rotate = 270;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            rotate = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            rotate = 90;
            break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return rotate;
}

From source file:ark.util.FileUtil.java

public static String readFile(File file) {
    return readFile(file.getAbsolutePath());
}