List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static String getCacheDir() { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { File cacheFile = mAppContext.getExternalCacheDir(); if (null != cacheFile) { return cacheFile.getPath(); }/*w w w.j a va2 s . c o m*/ } return mAppContext.getCacheDir().getPath(); }
From source file:com.sunchenbin.store.feilong.core.io.SpecialFolder.java
/** * (),?360.// ww w . j a v a 2 s .c om * <ul> * <li>win7:D:\noMove\documents</li> * </ul> * * @return ? * @see FileSystemView#getDefaultDirectory() */ public static String getMyDocuments() { FileSystemView fileSystemView = FileSystemView.getFileSystemView(); File file = fileSystemView.getDefaultDirectory(); return file.getPath(); }
From source file:Main.java
public static File getBlobPath(Context context) { File cachedir = context.getCacheDir(); if (cachedir == null) return null; return new File(cachedir.getPath() + File.separatorChar + "blob"); }
From source file:com.mycompany.hdp.hdp.java
private static void copyFilesToDir(String srcDirPath, FileSystem fs, String destDirPath) throws IOException { File dir = new File(srcDirPath); for (File file : dir.listFiles()) { fs.copyFromLocalFile(new Path(file.getPath()), new Path(destDirPath, file.getName())); }/*from w w w. j a va 2 s .c om*/ }
From source file:Main.java
public static long getSdCardAvailableSize() { File sdcardDir = Environment.getExternalStorageDirectory(); StatFs sf = null;//ww w . j av a 2s .co 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:Main.java
public static boolean isDirectoryValid(String path) { File file = new File(path); if (!file.canWrite()) { return false; }//from w w w . ja v a 2 s . c o m StatFs sf = new StatFs(file.getPath()); long availCount = sf.getAvailableBlocks(); if (availCount > 0) { return true; } return false; }
From source file:com.feilong.commons.core.io.SpecialFolder.java
/** * (),?360./*from www. j a va2s . c o m*/ * <ul> * <li>win7:D:\noMove\documents</li> * </ul> * * @return ? * @see FileSystemView#getDefaultDirectory() */ public static final String getMyDocuments() { FileSystemView fileSystemView = FileSystemView.getFileSystemView(); File file = fileSystemView.getDefaultDirectory(); return file.getPath(); }
From source file:com.norconex.commons.wicket.markup.html.filesystem.FileSystemTreeProvider.java
public static boolean isWindowsRoot(File file) { return SystemUtils.IS_OS_WINDOWS && file.getPath().equals(SystemUtils.FILE_SEPARATOR); }
From source file:Main.java
public static void deleteFile(String fileName) { File file = new File(fileName); if (file.exists()) { if (file.isDirectory()) { if (file.listFiles().length == 0) { file.delete();//from w w w . ja v a 2s . c o m } else { for (File f : file.listFiles()) { if (f.isDirectory()) { deleteFile(f.getPath()); } else { f.delete(); } } file.delete(); } } else { file.delete(); } } }
From source file:melnorme.utilbox.misc.FileUtil.java
public static int getNameCount(File file) { String[] tokens = file.getPath().split(File.separator); return tokens.length; }