List of utility methods to do File Create
void | ensureWorldReadable(File f) ensure World Readable File parent = f.getParentFile();
if (parent != null && !parent.exists()) {
ensureWorldReadable(parent);
parent.mkdir();
parent.setReadable(true, false);
parent.setExecutable(true, false);
|
void | ensureWorldWriteable(File f) ensure World Writeable File parent = f.getParentFile();
if (parent != null && !parent.exists()) {
ensureWorldWriteable(parent);
parent.mkdir();
parent.setWritable(true, false);
parent.setExecutable(true, false);
|
void | ensureWriteable(File f) Ensures that the directories for the file exist File parent = f.getParentFile();
if (parent != null) {
parent.mkdirs();
|
File | getFile(File basedir, String path) get File File file = new File(path); if (file.isAbsolute()) { return file; return new File(basedir, path); |
File | getFile(String filepath) get File File f = new File(filepath); if (!f.exists()) { f = new File("war", filepath); return f; |
File | getOutputMediaFile(Context context) get Output Media File File mediaStorageDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { return null; String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm") ... |
boolean | makeFile(File file) make File boolean result = false; makeParent(file); if (!file.exists()) { result = file.createNewFile(); return result; |
void | makeFile(String destinctionFile) make File File f = new File(destinctionFile); File pf = f.getParentFile(); if (f.exists()) return; if (!pf.exists()) { pf.mkdirs(); try { ... |
File | overwriteFile(File file) overwrite File if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); if (file.exists()) { if (!file.delete()) { throw new IOException("Unable to delete output file"); if (!file.createNewFile()) { throw new IOException("Unable to create output file"); return file; |
boolean | verifyCanCreateFile(final String path, final long length) Checks if a file with a specified size can be created on a specified path. final File file = new File(path); if (!file.exists()) { final RandomAccessFile access; try { access = new RandomAccessFile(file, "rws"); } catch (FileNotFoundException e) { return false; try { access.setLength(length); access.close(); } catch (IOException e) { return false; return file.delete(); return false; |