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 String getCachePath() { return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath() + File.separator + "MyCamera"; }
From source file:com.splunk.shuttl.archiver.util.UtilsURI.java
/** * Trim eventual ending {@link File#separator}.<br/> * Ex:<br/>/*from w ww .ja v a 2 s.c o m*/ * * <pre> * "file:/a/b/c" -> "/a/b/c" * "file:/a/b/c/" -> "/a/b/c" * "file:/a/b/c.txt" -> "/a/b/c.txt" * </pre> */ public static String getPathByTrimmingEndingFileSeparator(URI uri) { String path = uri.getPath(); if (path.endsWith(File.separator)) return path.substring(0, path.length() - 1); else return path; }
From source file:Main.java
public static void extractEntryContent(ZipInputStream zis, ZipEntry entry, String unzipdir) throws IOException, FileNotFoundException { String entryFileName = entry.getName(); String entryPath = unzipdir + File.separator + entryFileName; createFile(entryPath);/*from www .j a v a2s .co m*/ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(entryPath)); byte[] buffer = new byte[1024]; int count = -1; while ((count = zis.read(buffer)) != -1) { bos.write(buffer, 0, count); } bos.close(); }
From source file:Main.java
/** * @param context/*from w ww. ja v a2s.c o m*/ * @param dirName Only the folder name, not contain full path. * @return app_cache_path/dirName */ public static String getDiskCacheDir(Context context, String dirName) { final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ? context.getExternalCacheDir().getPath() : context.getCacheDir().getPath(); return cachePath + File.separator + dirName; }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. */// w w w .j a va2 s . co m public static File getOutputMediaFile(File myDir) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. Log.i("CameraSample", "about to check state of external storage"); if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { Log.d("CameraSample", "externalstoragestate was " + Environment.getExternalStorageState()); return null; } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = new File(myDir + File.separator + "VID_" + timeStamp + ".mp4"); return mediaFile; }
From source file:Main.java
public static String asUriFragment(String appName, File fileUnderAppName) { String relativePath = asRelativePath(appName, fileUnderAppName); String separatorString;// w ww .j a va 2 s.c o m if (File.separatorChar == '\\') { // Windows Robolectric separatorString = File.separator + File.separator; } else { separatorString = File.separator; } String[] segments = relativePath.split(separatorString); StringBuilder b = new StringBuilder(); boolean first = true; for (String s : segments) { if (!first) { b.append("/"); // uris have forward slashes } first = false; b.append(s); } return b.toString(); }
From source file:io.onedecision.engine.decisions.test.MockMultipartFileUtil.java
public static MultipartFile newInstance(String dmnResource) { File baseDir = new File("target" + File.separator + "test-classes"); File dmnToUpload = new File(baseDir, dmnResource); assertTrue("Cannot find DMN file to use as test input", dmnToUpload.exists()); Path path = Paths.get(dmnToUpload.getAbsolutePath()); String name = "file.dmn"; String originalFileName = "file.dmn"; String contentType = "application/xml"; byte[] content = null; try {/*from w ww. j a v a2 s . c o m*/ content = Files.readAllBytes(path); } catch (final IOException e) { } MultipartFile mpf = new MockMultipartFile(name, originalFileName, contentType, content); return mpf; }
From source file:Main.java
public static String getDataFolder(String appName) { String path = getAppFolder(appName) + File.separator + DATA_FOLDER_NAME; return path; }
From source file:Main.java
public static String getLogFile() { // TODO Auto-generated method stub return Environment.getExternalStorageDirectory() + File.separator + LOGS_FOLDER + File.separator + "log4j.txt"; }
From source file:net.orpiske.ssps.common.repository.utils.InstallDirUtils.java
/** * Gets the work dir/* w w w . j av a2s .c o m*/ * @return the work dir */ public static String getInstallDir() { return config.getString("user.install.dir", FileUtils.getUserDirectoryPath() + File.separator + "software"); }