List of usage examples for java.io File getAbsolutePath
public String getAbsolutePath()
From source file:Main.java
public static String getCacheFilename() { File f = getSavePath(); return f.getAbsolutePath() + "/cache.png"; }
From source file:Main.java
public static String relative(final File base, final File file) { final int rootLength = base.getAbsolutePath().length(); final String absFileName = file.getAbsolutePath(); return absFileName.substring(rootLength + 1); }
From source file:Main.java
/** * <pre>//from ww w . j a va 2 s.c o m * Get absolute path in app 's cache folder from relative path. * </pre> */ public static String getCacheAsbPath(String relativePath) { File cacheDir = getCurrentContext().getCacheDir(); return cacheDir.getAbsolutePath().concat("/").concat(relativePath); }
From source file:Main.java
public static Bitmap decodeFile(File file, BitmapFactory.Options options) { return BitmapFactory.decodeFile(file.getAbsolutePath(), options); }
From source file:Main.java
public static String clazzName(final File base, final File file) { final int rootLength = base.getAbsolutePath().length(); final String absFileName = file.getAbsolutePath(); final int p = absFileName.lastIndexOf('.'); final String relFileName = absFileName.substring(rootLength + 1, p); return relFileName.replace(File.separatorChar, '.'); }
From source file:Main.java
public static String getInternalFilesDir(Context context) { File file = context.getFilesDir(); if (file != null) { return file.getAbsolutePath(); }//from ww w . j a v a2 s.com return null; }
From source file:com.telecel.utils.FileUtils.java
public static String getExtension(File file) { String ext;/* w w w.j av a 2 s . c o m*/ ext = FilenameUtils.getExtension(file.getAbsolutePath()); return ext; }
From source file:Main.java
public static Bitmap getPic(File file, int width, int height) { String uri = file.getAbsolutePath(); // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(uri, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / width, photoH / height); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true;//ww w . j a v a 2 s . c o m return BitmapFactory.decodeFile(uri, bmOptions); }
From source file:Main.java
public static FileFilter getFileFilter(final String reg, boolean isdir) { if (isdir) {//from w ww .j a va 2s . c om return new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getAbsolutePath().toLowerCase().matches(reg) || pathname.isDirectory(); } }; } else { return new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getAbsolutePath().toLowerCase().matches(reg) && pathname.isFile(); } }; } }
From source file:Main.java
public static File convertFormat(File file, String newFormat) { StringBuilder tmpValue = new StringBuilder(file.getAbsolutePath()); int index = tmpValue.lastIndexOf(".") + 1; tmpValue.delete(index, tmpValue.length()); tmpValue.append(newFormat);/*from w w w . j ava 2 s . c o m*/ File result = new File(tmpValue.toString()); return result; }