List of usage examples for java.io File toString
public String toString()
From source file:com.textocat.textokit.morph.opencorpora.resource.GramModelDeserializer.java
public static GramModel from(File file) throws Exception { return from(FileUtils.openInputStream(file), file.toString()); }
From source file:Main.java
/** * Store a picture that has just been saved to disk in the MediaStore. * /* ww w .ja v a 2 s. co m*/ * @param imageFile * The File of the picture * @return The Uri provided by the MediaStore. */ public static Uri storePicture(Context ctx, File imageFile, String imageName) { ContentResolver cr = ctx.getContentResolver(); imageName = imageName.substring(imageName.lastIndexOf('/') + 1); ContentValues values = new ContentValues(7); values.put(Images.Media.TITLE, imageName); values.put(Images.Media.DISPLAY_NAME, imageName); values.put(Images.Media.DESCRIPTION, ""); values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis()); values.put(Images.Media.MIME_TYPE, "image/jpeg"); values.put(Images.Media.ORIENTATION, 0); File parentFile = imageFile.getParentFile(); String path = parentFile.toString().toLowerCase(); String name = parentFile.getName().toLowerCase(); values.put(Images.ImageColumns.BUCKET_ID, path.hashCode()); values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, name); values.put("_data", imageFile.toString()); Uri uri = cr.insert(sStorageURI, values); return uri; }
From source file:TraverseDirectory.java
public static void recursieTraverseDirectory(String path) throws FileNotFoundException, IOException { File file = new File(path); //It will List all the files and subdirectores file if it is Set to True Collection<File> files = FileUtils.listFiles(file, null, true); for (File file2 : files) { String filter = ".txt"; //Extension for Filtering the file if (file2.toString().endsWith(filter)) { //Function call to Traverse the file with .txt extension traveseFile(file2.toString()); }/*from w w w . ja v a2 s. c o m*/ } }
From source file:Main.java
public static boolean deleteFile(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); if (!fileName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + fileName); checker.checkDelete(newPath.toString()); if (newPath.isFile()) { try { Log.i("DirectoryManager deleteFile", fileName); newPath.delete();//from ww w . j ava 2 s .c o m status = true; } catch (SecurityException se) { se.printStackTrace(); status = false; } } else status = false; } else status = false; return status; }
From source file:com.smash.revolance.ui.tests.smoke.ServerLifecycleITest.java
public static List<String> listDistribFiles() { List<String> files = new ArrayList<>(); List<File> distribFiles = (List<File>) FileUtils.listFiles(DISTRIB_DIR, null, true); for (File file : distribFiles) { files.add(file.toString()); }/*from w ww . jav a2s. com*/ return files; }
From source file:Main.java
public static byte[] readZipEntry(File zfile, ZipEntry entry) throws ZipException, IOException { Log.d("file3: ", zfile.toString()); Log.d("zipEntry3: ", entry.toString()); ZipFile zipFile = new ZipFile(zfile); if (entry != null && !entry.isDirectory()) { byte[] barr = new byte[(int) entry.getSize()]; int read = 0; int len = 0; InputStream is = zipFile.getInputStream(entry); BufferedInputStream bis = new BufferedInputStream(is); int length = barr.length; while ((len = bis.read(barr, read, length - read)) != -1) { read += len;//from ww w . ja v a 2 s . c o m } bis.close(); is.close(); zipFile.close(); return barr; } else { zipFile.close(); return new byte[0]; } }
From source file:net.skyebook.zerocollada.ZeroCollada.java
private static File removeOldXYZTag(File file) { if (file.toString().contains("x_")) { return new File(file.toString().substring(0, file.toString().indexOf("x_")) + ".dae"); } else/*from www.ja v a 2 s.c om*/ return file; }
From source file:Main.java
public static void validateNotExists(File f) throws IOException { if (f.exists()) { throw new IOException(String.format("%s exists, please choose another file\n", f.toString())); }/*from w w w .j ava 2s . c o m*/ }
From source file:Main.java
public static boolean deleteDirectory(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); if (!fileName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + fileName); checker.checkDelete(newPath.toString()); if (newPath.isDirectory()) { String[] listfile = newPath.list(); // delete all files within the specified directory and then // delete the directory try { for (int i = 0; i < listfile.length; i++) { File deletedFile = new File(newPath.toString() + "/" + listfile[i].toString()); deletedFile.delete(); }/*from w w w . j a v a 2 s . co m*/ newPath.delete(); Log.i("DirectoryManager deleteDirectory", fileName); status = true; } catch (Exception e) { e.printStackTrace(); status = false; } } else status = false; } else status = false; return status; }
From source file:Main.java
public static boolean deleteDirectory(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); if (!fileName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + fileName); checker.checkDelete(newPath.toString()); if (newPath.isDirectory()) { String[] listfile = newPath.list(); // delete all files within the specified directory and then // delete the directory try { for (int i = 0; i < listfile.length; i++) { File deletedFile = new File(newPath.toString() + "/" + listfile[i].toString()); deletedFile.delete(); }// w w w.ja v a2 s . c om newPath.delete(); Log.d(TAG, "DirectoryManager deleteDirectory" + fileName); status = true; } catch (Exception e) { e.printStackTrace(); status = false; } } else status = false; } else status = false; return status; }