List of usage examples for java.io File separator
String separator
To view the source code for java.io File separator.
Click Source Link
From source file:Main.java
public static File getDiskCacheFile(Context context, String key) { final String cachePath = context.getFilesDir().getPath(); File cacheDir = new File(cachePath + File.separator + DISK_CACHE_SUBDIR); if (!cacheDir.exists()) { cacheDir.mkdir();//from w w w. jav a 2 s .co m } return new File(cacheDir + File.separator + key); }
From source file:Main.java
public static void writeBuffer2InternalStorage(String path, byte[] data) { File file = new File(_context.getFilesDir() + File.separator + path); try {//from w w w .ja va2 s.c o m FileOutputStream outstream; if (!file.exists()) { file.createNewFile(); } outstream = new FileOutputStream(file); outstream.write(data); outstream.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static String getExternalStoragePath() { StringBuilder sb = new StringBuilder(); sb.append(Environment.getExternalStorageDirectory().getAbsolutePath()); sb.append(File.separator); sb.append(ROOT_DIR);/*from w w w. ja va 2s.c o m*/ sb.append(File.separator); return sb.toString(); }
From source file:Main.java
public static String getOdkFolder() { String path = Environment.getExternalStorageDirectory() + File.separator + "opendatakit"; return path;//from w ww .j av a 2s.c o m }
From source file:Main.java
public static boolean debugRmDir(String dir, boolean deleteDirectory) { File directory = new File(dir); if (directory.isDirectory()) { String[] children = directory.list(); for (String s : children) { if (!debugRmDir(dir + File.separator + s, true)) return false; }//from w w w . j a va 2s. co m } return !deleteDirectory || directory.delete(); }
From source file:Main.java
public static void dumpHprof(String path) { try {//from www . j a v a 2s.c om String name = getDate() + OOM_SUFFIX; path = path + File.separator + name; File file = path != null ? new File(path) : null; if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); Debug.dumpHprofData(path); } catch (Throwable t) { t.printStackTrace(); } }
From source file:Main.java
public static File createFile(String path) throws IOException { if (notEmptyOrNull(path)) { File file = new File(path); if (!file.exists()) { int lastIndex = path.lastIndexOf(File.separator); String dir = path.substring(0, lastIndex); if (createFolder(dir) != null) { file.createNewFile();//from w ww . jav a 2 s. c o m return file; } } else { file.createNewFile(); return file; } } return null; }
From source file:Main.java
public static String getModelPath(String modelName, Context mContext) { String path = null;/*from w w w .jav a 2 s. c o m*/ File dataDir = mContext.getApplicationContext().getExternalFilesDir(null); if (dataDir != null) { path = dataDir.getAbsolutePath() + File.separator + modelName; } return path; }
From source file:Main.java
public static File getAlbumFolder(String albumName) { File folder = new File(Environment.getExternalStorageDirectory() + File.separator + albumName); if (!folder.exists()) { folder.mkdir();/*www . j ava 2 s . c o m*/ try { new File(folder, ".yesmedia").createNewFile(); } catch (Exception e) { Log.d(TAG, "[AirImagePickerUtils] exception = " + e.getMessage()); Log.d(TAG, "[AirImagePickerUtils] Exiting didSavePictureInGallery (failed)"); return null; } } return folder; }
From source file:Main.java
public static String stripExtension(String inputString) { int lastIndex = inputString.lastIndexOf("."); if (lastIndex < 0) { return inputString; }//w w w . j a v a 2 s. c om int fileSeparatorLastIndex = inputString.lastIndexOf(File.separator); if (fileSeparatorLastIndex < 0 && lastIndex == 0) { return inputString; } if (fileSeparatorLastIndex >= 0 && fileSeparatorLastIndex > lastIndex) { return inputString; } return inputString.substring(0, lastIndex); }