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 getTablesFolder(String appName) { String path = getAppFolder(appName) + File.separator + TABLES_FOLDER_NAME; return path; }
From source file:Main.java
public static String getAppFolder(String appName) { String path = getOdkFolder() + File.separator + appName; return path; }
From source file:Main.java
public static float[] readBinAverageShapeArray(String dir, String fileName, int size) { float x;/*from w ww . j av a 2 s . c o m*/ int i = 0; float[] tab = new float[size]; // theses values was for 64140 points average shape //float minX = -90.3540f, minY = -22.1150f, minZ = -88.7720f, maxX = 101.3830f, maxY = 105.1860f, maxZ = 102.0530f; // values for average shape after simplification (8489 points) float maxX = 95.4549f, minX = -85.4616f, maxY = 115.0088f, minY = -18.0376f, maxZ = 106.7329f, minZ = -90.4051f; float deltaX = (maxX - minX) / 2.0f; float deltaY = (maxY - minY) / 2.0f; float deltaZ = (maxZ - minZ) / 2.0f; float midX = (maxX + minX) / 2.0f; float midY = (maxY + minY) / 2.0f; float midZ = (maxZ + minZ) / 2.0f; File sdLien = Environment.getExternalStorageDirectory(); File inFile = new File(sdLien + File.separator + dir + File.separator + fileName); Log.d(TAG, "path of file : " + inFile); if (!inFile.exists()) { throw new RuntimeException("File doesn't exist"); } DataInputStream in = null; try { in = new DataInputStream(new FileInputStream(inFile)); } catch (FileNotFoundException e) { e.printStackTrace(); } try { //read first x x = in.readFloat(); //Log.d(TAG,"first Vertices = "+x); while (true) { tab[i] = (x - midX) / deltaX; //rescale x i++; //read y x = in.readFloat(); tab[i] = (x - midY) / deltaY; //rescale y i++; //read z x = in.readFloat(); tab[i] = (x - midZ) / deltaZ; //rescale z i++; //read x x = in.readFloat(); } } catch (EOFException e) { try { Log.d(TAG, "close"); in.close(); } catch (IOException e1) { e1.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { //free ressources Log.d(TAG, "close"); in.close(); } catch (IOException e) { e.printStackTrace(); } } } return tab; }
From source file:Main.java
/** * Gets the current application cache directory path in private storage. * * @param context Any context./*from w ww . j a va 2 s .com*/ * @return The default application cache directory path. */ public static String getCacheDirPathName(Context context) { return context.getApplicationContext().getCacheDir() + File.separator + getCacheDirName(); }
From source file:Main.java
public static File getDiskAppCacheDir(Context context, String uniqueName) { // Check if media is mounted or storage is built-in, if so, try and use // external cache dir // otherwise use internal cache dir final File externalCache = getExternalCacheDir(context); final String cachePath = (externalCache == null) ? context.getCacheDir().getPath() : externalCache.getPath();//from w ww . j a v a2 s . co m return new File(cachePath + File.separator + uniqueName); }
From source file:Main.java
public static void unZip(InputStream zipFileIS, String outputFolder) throws IOException { byte[] buffer = new byte[1024]; //create output directory is not exists File folder = new File(outputFolder); if (!folder.exists()) { folder.mkdir();//from w w w.j av a 2 s .c o m } //get the zip file content ZipInputStream zis = new ZipInputStream(zipFileIS); //get the zipped file list entry ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFolder + File.separator + fileName); if (ze.isDirectory()) { newFile.mkdirs(); } else { FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.flush(); fos.close(); } ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); }
From source file:FileUtils.java
/** * Convert a list of path elements to a platform-specific path. * /*from ww w. j av a2 s . co m*/ * @param strings * Elements in a path * @return an absolute path using the current platform's * <code>File.separator</code> */ public static String makePath(String[] strings) { String result = ""; for (int i = 0; i < strings.length; i++) result += File.separator + strings[i]; return result; }
From source file:Main.java
public static File getDestinationInExternalPublicDir(String dirType, String fileName) { File file = Environment.getExternalStoragePublicDirectory(dirType); if (file.exists()) { if (!file.isDirectory()) { throw new IllegalStateException(file.getAbsolutePath() + " already exists and is not a directory"); }// www. j a v a2 s .c o m } else { if (!file.mkdirs()) { throw new IllegalStateException("Unable to create directory: " + file.getAbsolutePath()); } } //mDestinationUri = Uri.withAppendedPath(Uri.fromFile(file), subPath); /*File destFolder = new File(file.getAbsolutePath() + File.separator + DOWNLOAD_FOLDER); if (destFolder.exists()) { if (!destFolder.isDirectory()) { throw new IllegalStateException(file.getAbsolutePath() + " already exists and is not a directory"); } } else { if (!destFolder.mkdirs()) { throw new IllegalStateException("Unable to create directory: "+ destFolder.getAbsolutePath()); } } File destFile = new File(destFolder.getAbsolutePath() + File.separator + fileName);*/ return new File(file.getAbsolutePath() + File.separator + fileName); }
From source file:Main.java
public static void unZip(String zipFile, String outputFolder) throws IOException { byte[] buffer = new byte[1024]; //create output directory is not exists File folder = new File(outputFolder); if (!folder.exists()) { folder.mkdir();/*from w w w . j a v a 2 s . co m*/ } //get the zip file content ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); //get the zipped file list entry ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFolder + File.separator + fileName); //create all non exists folders //else you will hit FileNotFoundException for compressed folder if (ze.isDirectory()) newFile.mkdirs(); else { newFile.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.close(); } ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); }