List of usage examples for java.io File toString
public String toString()
From source file:com.phonegap.DirectoryManager.java
/** * Delete file./*from www. j a v a 2 s . c o m*/ * * @param fileName The name of the file to delete * @return T=deleted, F=not deleted */ protected static boolean deleteFile(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); // Make sure SD card exists if ((testSaveLocationExists()) && (!fileName.equals(""))) { File path = Environment.getExternalStorageDirectory(); File newPath = constructFilePaths(path.toString(), fileName); checker.checkDelete(newPath.toString()); // If file to delete is really a file if (newPath.isFile()) { try { Log.i("DirectoryManager deleteFile", fileName); newPath.delete(); status = true; } catch (SecurityException se) { se.printStackTrace(); status = false; } } // If not a file, then error else { status = false; } } // If no SD card else { status = false; } return status; }
From source file:com.wallerlab.compcellscope.Image_Gallery.java
public static File[] removeElements(File[] input, String deleteMe) { ArrayList<File> result = new ArrayList<File>(); Log.d("Image_Gallery", "Got here: " + input.length); for (File item : input) if (!item.toString().contains(deleteMe)) result.add(item);//from www . j a v a2 s . co m Log.d("Image_Gallery", "Got here: " + result.size()); return result.toArray(new File[result.size()]); }
From source file:com.phonegap.DirectoryManager.java
/** * Delete directory./*from w ww .j a v a 2 s.c o m*/ * * @param fileName The name of the directory to delete * @return T=deleted, F=could not delete */ protected static boolean deleteDirectory(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); // Make sure SD card exists if ((testSaveLocationExists()) && (!fileName.equals(""))) { File path = Environment.getExternalStorageDirectory(); File newPath = constructFilePaths(path.toString(), fileName); checker.checkDelete(newPath.toString()); // If dir to delete is really a directory 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(); } newPath.delete(); Log.i("DirectoryManager deleteDirectory", fileName); status = true; } catch (Exception e) { e.printStackTrace(); status = false; } } // If dir not a directory, then error else { status = false; } } // If no SD card else { status = false; } return status; }
From source file:org.meshpoint.anode.util.ModuleUtils.java
public static File unpack(File moduleResource, String moduleName, ModuleType modType) throws IOException { /* create temp dir to unpack; assume no hash collision */ String tmpDirName = moduleName + '-' + String.valueOf(counter++) + "-tmp"; File result = new File(resourceDir, tmpDirName); if (!result.isDirectory() && !result.mkdir()) throw new IOException("Unable to create tmp directory to unpack: " + result.toString()); if (modType.unpacker != null) { modType.unpacker.unpack(moduleResource, result); } else {/*from ww w.j ava 2 s . c o m*/ Log.v(TAG, "ModuleUtils.unpack(): aborting (internal error)"); result = null; } return result; }
From source file:com.ning.metrics.collector.hadoop.processing.LocalSpoolManager.java
public static void cleanupOldSpoolDirectories(final Iterable<File> oldSpoolDirectories) { // Cleanup empty directories /_tmp, /_quarantine and /_lock first for (final File dir : oldSpoolDirectories) { for (final File subDir : dir.listFiles()) { if (subDir.isDirectory() && subDir.listFiles().length == 0) { log.info(String.format("Deleting empty directory: %s", subDir.toString())); FileUtils.deleteQuietly(subDir); }//from w w w.j av a 2s. co m } } for (final File dir : oldSpoolDirectories) { if (dir.isDirectory() && dir.listFiles().length == 0) { log.info(String.format("Deleting empty directory: %s", dir.toString())); FileUtils.deleteQuietly(dir); } } }
From source file:com.ibm.watson.developer_cloud.retrieve_and_rank.v1.util.ZipUtils.java
private static byte[] readBytes(File file) { FileInputStream in = null;/*from w w w. ja v a 2 s. c om*/ final byte buffer[] = new byte[(int) file.length()]; try { in = new FileInputStream(file); in.read(buffer); } catch (final IOException e) { MSGS.format(ERROR_READING_FILE_1, file.toString(), e); } if (in != null) { try { in.close(); } catch (final IOException e) { // fail quietly } } return buffer; }
From source file:de.dfki.resc28.ole.bootstrap.App.java
public static synchronized void configure() { try {/*w w w . java 2s . c o m*/ String configFile = System.getProperty("bootstrap.configuration"); java.io.InputStream is; if (configFile != null) { is = new java.io.FileInputStream(configFile); System.out.format("Loading OLE Bootstrapper configuration from %s ...%n", configFile); } else { is = App.class.getClassLoader().getResourceAsStream("bootstrap.properties"); System.out.println("Loading OLE Bootstrapper configuration from internal resource file ..."); } java.util.Properties p = new Properties(); p.load(is); fBaseURI = getProperty(p, "baseURI", "bootstrap.baseURI"); fStorageURI = getProperty(p, "storageURI", "bootstrap.storageURI"); fAssetBaseUri = Util.joinPath(App.fBaseURI, "repo/assets"); fDistributionBaseUri = Util.joinPath(App.fBaseURI, "repo/distributions"); fUserBaseUri = Util.joinPath(App.fBaseURI, "repo/users"); fPartsDirectory = getProperty(p, "partsDirectory", "bootstrap.partsDirectory"); String storage = getProperty(p, "graphStore", "bootstrap.graphStore"); if (storage.equals("fuseki")) { String dataEndpoint = getProperty(p, "dataEndpoint", "bootstrap.dataEndpoint"); String queryEndpoint = getProperty(p, "queryEndpoint", "bootstrap.queryEndpoint"); System.out.format("Use Fuseki backend:%n dataEndpoint=%s%n queryEndpoint=%s ...%n", dataEndpoint, queryEndpoint); fGraphStore = new FusekiGraphStore(dataEndpoint, queryEndpoint); } // Overriders if (fPartsDirectory == null || !new File(fPartsDirectory).isDirectory()) { String ldrawDir = System.getenv("LDRAWDIR"); if (ldrawDir != null) { File dir = new File(ldrawDir); if (dir.isDirectory()) { dir = new File(dir, "parts"); if (dir.isDirectory()) { fPartsDirectory = dir.toString(); } } } } System.out.format("Use LDraw parts directory: %s%n", fPartsDirectory); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveDBInSdcard(Context pContext, String pDatabaseName) { try {//from w ww . j a v a 2 s . co m File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + pContext.getPackageName() + "//databases//" + pDatabaseName; String backupDBPath = pDatabaseName; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); FileChannel src = new FileInputStream(currentDB).getChannel(); FileChannel dst = new FileOutputStream(backupDB).getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); Toast.makeText(pContext, backupDB.toString(), Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(pContext, e.toString(), Toast.LENGTH_LONG).show(); } }
From source file:com.thenairn.linker.config.Libraries.java
/** * Puts library to temp dir and loads to memory *///from w ww. j a v a 2 s. c om private static void loadLib(String path, String name) { name = name + ".dll"; try { // have to use a stream InputStream in = Libraries.class.getResourceAsStream(LIB_BIN + name); // always write to different location File fileOut = new File(System.getProperty("java.io.tmpdir") + "/" + path + LIB_BIN + name); logger.info("Writing dll to: " + fileOut.getAbsolutePath()); OutputStream out = FileUtils.openOutputStream(fileOut); IOUtils.copy(in, out); in.close(); out.close(); System.load(fileOut.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.aurel.track.dbase.InitProjectTypesBL.java
public static void addProjectTypes(String initDataDir) { File directory = null; directory = PluginUtils.getResourceFileFromWebAppRoot(ApplicationBean.getInstance().getServletContext(), initDataDir + "/ProjectTypes"); if (directory != null && directory.exists() && directory.isDirectory()) { LOGGER.info("Retrieving project type templates from " + directory.toString()); File[] files = directory.listFiles(new InitProjectTypesBL.Filter()); if (files == null || files.length == 0) { LOGGER.error("No project types files found."); return; }/*ww w .ja v a 2 s . com*/ for (int index = 0; index < files.length; index++) { File f = files[index]; importProjectTypes(f); } } }