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 List<String> getFile(String path, Integer count, String fileEnd, List<String> result) {
    File f = new File(path);
    File[] files = f.listFiles();

    for (File s : files) {
        if (s.isDirectory()) {
            getFile(s.getAbsolutePath(), count, fileEnd, result);
        } else {/*w ww .j a  v  a  2 s. c  o  m*/
            if (s.getName().toLowerCase().endsWith(fileEnd.toLowerCase())) {
                result.add(s.getAbsolutePath());
            }
        }
    }
    return result;
}

From source file:Main.java

public static void deleteAllFiles(File root) {
    if (root.exists()) {
        String deleteCmd = "rm -r " + root.getAbsolutePath();
        Runtime runtime = Runtime.getRuntime();
        try {/*from w  w w .java  2s .  c o  m*/
            runtime.exec(deleteCmd);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

/**
 * Clears any leftover photos in our temporary folder.
 *//*w w w  .j a v  a 2  s. c om*/
public static void clearPhotos() {
    File tempDir = Environment.getExternalStorageDirectory();
    tempDir = new File(tempDir.getAbsolutePath() + "/bv-temp/");
    if (tempDir.listFiles() != null) {
        for (File photo : tempDir.listFiles()) {
            photo.delete();
        }
    }
}

From source file:Main.java

/**
 * Get Image Orientation from file/*from   w ww .  j a  v  a  2 s  .  c om*/
 *
 * @param imageFile File for which orientation is changed
 * @return Current Orientation
 */
public static int getBitmapOrientation(File imageFile) {
    try {
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
    } catch (IOException e) {
    }
    return 0;
}

From source file:com.wavemaker.commons.util.ConversionUtils.java

public static List<Resource> convertToResourceList(List<File> files) {
    List<Resource> resources = new ArrayList<Resource>();
    for (File file : files) {
        String path = file.getAbsolutePath();
        if (file.isDirectory() && !path.endsWith("/")) {
            path += "/";
        }/*from   ww  w .  j a  va  2 s  .  co  m*/
        resources.add(new FileSystemResource(path));
    }
    return resources;
}

From source file:Main.java

public static String getVideoFilePath(Context context) {
    final File dir = context.getExternalFilesDir(null);
    return (dir == null ? "" : (dir.getAbsolutePath() + "/")) + System.currentTimeMillis() + ".mp4";
}

From source file:com.asociate.utils.Archivos.java

/**
 *
 * @param idUsuario/*from  w ww . j a v a2s .c  o  m*/
 * @return
 */
public static String comprobarFPerfl(Long idUsuario) {
    String uri = dir + "/" + idUsuario + "\\perfil.jpg";
    File file = new File(uri);
    System.out.println("El archivo: " + file.getAbsolutePath() + " es " + file.exists());
    return file.exists() ? file.getAbsolutePath() : "";
}

From source file:info.mikaelsvensson.devtools.common.PathUtils.java

private static String fixPath(final File source) {
    String fixed = source.getAbsolutePath();
    if (File.separatorChar != SEP) {
        fixed = fixed.replace(File.separatorChar, SEP);
    }/*from ww w.  j av a  2  s.co  m*/
    return source.isDirectory() ? trailingSlash(fixed) : fixed;
}

From source file:Main.java

public static void gunzip(File inFile, File outFile) {
    System.out.println("Expanding " + inFile.getAbsolutePath() + " to " + outFile.getAbsolutePath());

    FileOutputStream out = null;//from w ww.j a  v a 2s . c  o  m
    GZIPInputStream zIn = null;
    FileInputStream fis = null;
    try {
        out = new FileOutputStream(outFile);
        fis = new FileInputStream(inFile);
        zIn = new GZIPInputStream(fis);
        byte[] buffer = new byte[8 * 1024];
        int count = 0;
        do {
            out.write(buffer, 0, count);
            count = zIn.read(buffer, 0, buffer.length);
        } while (count != -1);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:Main.java

private static String resolve(String path) {
    File file = new File(path);
    if (file.exists()) {
        return file.getAbsolutePath();
    } else {/*from ww  w. j a v  a2 s  .  com*/
        return null;
    }
}