List of usage examples for java.io File canRead
public boolean canRead()
From source file:Main.java
static boolean isFileUseful(File file) { return file != null && file.exists() && file.canRead() && !file.isDirectory(); }
From source file:Main.java
public static boolean hasFileAccess(String filePath) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) { return true; }//from ww w. ja va 2 s . com File file = new File(filePath); if (file.canRead()) { return true; } else { return false; } }
From source file:Main.java
public static int getFileLines(File file) { if (!file.canRead() || !file.isFile()) { Log.w(LOG_TAG, CLASS + ": getLinesInFile: invalid file."); return -1; }/* w w w . ja v a2 s . c om*/ int lines = 0; try { BufferedReader reader = new BufferedReader(new FileReader(file)); while (reader.readLine() != null) lines++; reader.close(); } catch (Exception e) { e.printStackTrace(); } return lines; }
From source file:Main.java
public static void valiFileCanRead(File file) throws IOException { if (!file.canRead()) { throw new IOException("For file '" + file.getName() + "' not read access!"); }//from ww w . ja va 2s . c om }
From source file:Main.java
public static boolean canListFiles(File f) { try {/*from w ww.j ava 2 s .c o m*/ return f.canRead() && f.isDirectory(); } catch (Exception e) { return false; } }
From source file:Main.java
public static boolean isFBCanRW() { try {/*from w w w . ja va 2s . c om*/ File fbFile = new File("/dev/graphics/fb0"); return fbFile.canRead() && fbFile.canWrite(); } catch (Exception exception) { return false; } }
From source file:Main.java
/** * checks if the file exists and is readable *//* ww w .j a v a2 s. co m*/ public static boolean fileExistsAndCanRead(String filePath) { File f = new File(filePath); return (f.exists() && !f.isDirectory() && f.canRead()); }
From source file:Main.java
public static boolean isValidRoot(String root) { if (TextUtils.isEmpty(root)) return false; File rootFile = new File(root); return rootFile.exists() && rootFile.canRead() && rootFile.canWrite(); }
From source file:Main.java
/** * Tests if a folder is a RPG2k Game./* ww w . ja va2 s .c o m*/ * (contains DATABASE_NAME and TREEMAP_NAME) * * @param dir Directory to test * @return true if RPG2k game */ public static boolean isRpg2kGame(File dir) { if (!dir.isDirectory() || !dir.canRead()) { return false; } boolean databaseFound = false; boolean treemapFound = false; for (File entry : dir.listFiles()) { if (entry.isFile() && entry.canRead()) { if (!databaseFound && entry.getName().equalsIgnoreCase(DATABASE_NAME)) { databaseFound = true; } else if (!treemapFound && entry.getName().equalsIgnoreCase(TREEMAP_NAME)) { treemapFound = true; } if (databaseFound && treemapFound) { return true; } } } return false; }
From source file:Main.java
private static void readGpxDirectory(File dir, final List<String> list, String parent) { if (dir != null && dir.canRead()) { File[] files = dir.listFiles(); if (files != null) { for (File f : files) { if (f.getName().toLowerCase().endsWith(".gpx")) { //$NON-NLS-1$ list.add(parent + f.getName()); } else if (f.isDirectory()) { readGpxDirectory(f, list, parent + f.getName() + "/"); }/*ww w .jav a2 s. com*/ } } } }