List of usage examples for java.io File toString
public String toString()
From source file:Main.java
public static void intallApk(Context context, String filePath) { File apkfile = new File(filePath); if (!apkfile.exists()) return;//from ww w. j a v a 2s .c o m Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive"); context.startActivity(i); }
From source file:Main.java
private static void searchFiles(File root, List<File> files, String... extension) { if (root.isFile()) { for (String string : extension) { if (root.toString().endsWith(string)) { files.add(root);// w ww. j a v a 2s . co m } } } else { File[] children = root.listFiles(); if (children != null) { for (File file : children) { searchFiles(file, files, extension); } } } }
From source file:Main.java
public static String getSdCacheDir(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { java.io.File fExternalStorageDirectory = Environment.getExternalStorageDirectory(); java.io.File autonaviDir = new java.io.File(fExternalStorageDirectory, "amapsdk"); boolean result = false; if (!autonaviDir.exists()) { result = autonaviDir.mkdir(); }/* ww w. j a va 2 s. c o m*/ java.io.File minimapDir = new java.io.File(autonaviDir, "offlineMap"); if (!minimapDir.exists()) { result = minimapDir.mkdir(); } return minimapDir.toString() + "/"; } else { return ""; } }
From source file:com.mfalaize.zipdiff.Main.java
private static void checkFile(java.io.File f) { String filename = f.toString(); if (!f.exists()) { System.err.println("'" + filename + "' does not exist"); System.exit(EXITCODE_ERROR); }/*w w w. j a va 2 s . c o m*/ if (!f.canRead()) { System.err.println("'" + filename + "' is not readable"); System.exit(EXITCODE_ERROR); } if (f.isDirectory()) { System.err.println("'" + filename + "' is a directory"); System.exit(EXITCODE_ERROR); } }
From source file:Main.java
/** * Get SDCard cache dir.// w w w. j a va 2 s . c o m * * @param context * @return */ public static String getSdCacheDir(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { java.io.File fExternalStorageDirectory = Environment.getExternalStorageDirectory(); java.io.File autonaviDir = new java.io.File(fExternalStorageDirectory, "move"); boolean result = false; if (!autonaviDir.exists()) { result = autonaviDir.mkdir(); } java.io.File minimapDir = new java.io.File(autonaviDir, "offlineMap"); if (!minimapDir.exists()) { result = minimapDir.mkdir(); } return minimapDir.toString() + File.separator; } else { return ""; } }
From source file:Main.java
public static boolean installApk(Context context, String fileName) { File apkfile = new File(fileName); if (!apkfile.exists()) { return false; }/*from w w w . j a va 2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive"); context.startActivity(intent); return true; }
From source file:Main.java
public static String getSdCacheDir(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (true) { Context appContext = context.getApplicationContext(); File amap = appContext.getExternalFilesDir("offlineMap"); return amap.getAbsolutePath() + "/"; } else {/*from w w w. j av a 2 s . co m*/ File fExternalStorageDirectory = Environment.getExternalStorageDirectory(); File autonaviDir = new File(fExternalStorageDirectory, "amapsdk"); boolean result = false; if (!autonaviDir.exists()) { result = autonaviDir.mkdir(); } File minimapDir = new File(autonaviDir, "offlineMap"); if (!minimapDir.exists()) { result = minimapDir.mkdir(); } return minimapDir.toString() + "/"; } } else { return ""; } }
From source file:io.stallion.boot.MainRunner.java
static void setupWatchers(String targetPath) { List<File> directories = new ArrayList<>(); directories.add(new File(targetPath + "/js")); directories.add(new File(targetPath + "/conf")); if (new File(targetPath + "/plugins").isDirectory()) { for (File file : new File(targetPath + "/plugins").listFiles()) { if (file.isDirectory()) { directories.add(file);/*from w w w . j ava2 s . c om*/ } } } watcher = new FileSystemWatcherRunner(); for (File dir : directories) { Log.info("Watch folder {0}", dir.toString()); if (!dir.isDirectory()) { continue; } BaseWatchEventHandler handler = new DebugFileChangeHandler().setWatchTree(true) .setWatchedFolder(dir.getAbsolutePath()); if (dir.getAbsolutePath().endsWith("/conf")) { handler.setExtension(".toml"); } else { handler.setExtension(".js"); } watcher.registerWatcher(handler); } watcherThread = new Thread(watcher); watcherThread.setName("stallion-dev-mode-source-code-watcher"); watcherThread.start(); }
From source file:Main.java
public static void mediaScannerCall(final Context context, final File file) { new AsyncTask<Void, Void, Void>() { @Override/* w w w .j ava 2 s . c o m*/ protected Void doInBackground(Void... params) { MediaScannerConnection.scanFile(context, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); } }); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null); }
From source file:com.iggroup.oss.restdoclet.plugin.io.IOUtils.java
/** * Copies an input-stream to a file./*from w w w. ja v a 2s. com*/ * * @param input the input-stream. * @param output the output-file. * @param close <code>true</code> if the output-stream has to be closed * after copying. * @throws IOException if an input-output exception occurs. */ public static void copy(final InputStream input, final File output, final boolean close) throws IOException { LOG.debug("Copying " + output.toString()); copy(input, new FileOutputStream(output, false), close); }