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
/** * Store xml Signature represented by dom.Document into xml file * @param doc - XML Signature//w ww . ja v a 2 s .com * @param fileName - name of output file */ public static boolean storeSignatureToXMLFile(Document doc, String fileName) { boolean stored = false; OutputStream os; File absolute = new File(fileName); String outputPath = new String(); if (absolute.getParentFile().isAbsolute()) { outputPath = fileName; //path is absolute } else { outputPath = baseDir + File.separator + fileName; //relative, store it into %project_dir%/dist/signatures } File file = new File(outputPath); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } try { os = new FileOutputStream(outputPath); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); //trans.setOutputProperty(OutputKeys.ENCODING, "utf-8"); //trans.setOutputProperty(OutputKeys.INDENT, "no"); //trans.setOutputProperty(OutputKeys.METHOD, "xml"); trans.transform(new DOMSource(doc), new StreamResult(os)); stored = true; } catch (FileNotFoundException e) { handleError(e); } catch (TransformerConfigurationException e) { handleError(e); } catch (TransformerException e) { handleError(e); } return stored; }
From source file:mesclasses.util.EleveFileUtil.java
public static File getEleveDirWithType(Eleve eleve, String type) { return new File(FileConfigurationManager.getInstance().getUploadDir() + File.separator + sanitize(eleve.getId()) + File.separator + type); }
From source file:Main.java
public static String getDirectory(String foldername) { // if (!foldername.startsWith(".")) { // foldername = "." + foldername; // }// w w w . ja v a2 s . c om File directory = null; directory = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + foldername); if (!directory.exists()) { directory.mkdirs(); } return directory.getAbsolutePath(); }
From source file:melnorme.utilbox.misc.FileUtil.java
public static int getNameCount(File file) { String[] tokens = file.getPath().split(File.separator); return tokens.length; }
From source file:iqq.app.IMLauncher.java
/** * ???// ww w.j a va 2s. c om */ private static void init() { // APP String path = System.getProperty("user.dir"); if (new File(path + File.separator + "resources").exists()) { System.setProperty("app.dir", new File(path).getAbsolutePath()); } else { // ?main path = path.substring(0, path.lastIndexOf(File.separator)); System.setProperty("app.dir", new File(path).getAbsolutePath()); } LOG.info("app.dir = " + System.getProperty("app.dir")); // ? Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { shutdown(); } })); LOG.info("init..."); }
From source file:Main.java
/** * Construct the path to the directory containing the default form (holding * the Common Javascript Framework)./* ww w . j a va2s . com*/ * * @param appName * @return */ public static String getFrameworkFolder(String appName) { String path = getAppFolder(appName) + File.separator + FRAMEWORK_FOLDER_NAME; return path; }
From source file:Main.java
public static String getTablesDebugObjectFolder(String appName) { String outputFolder = getOutputFolder(appName); String result = outputFolder + File.separator + DEBUG_FOLDER_NAME; return result; }
From source file:Main.java
/** * Create a File for saving an image or video *//*ww w. j a v a2 s . co m*/ @SuppressLint("SimpleDateFormat") public static File getOutputMediaFile(int type, Context context) { // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = null; if (type == MEDIA_TYPE_IMAGE) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "StoryCapture"); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("StoryCapture", "failed to create directory"); return null; } } mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_AUDIO) { String fileName = "AUDIO_" + timeStamp + ".3gp"; mediaFile = new File(context.getFilesDir(), fileName); } return mediaFile; }
From source file:Main.java
public static String asConfigRelativePath(String appName, File fileUnderAppConfigName) { String relativePath = asRelativePath(appName, fileUnderAppConfigName); if (!relativePath.startsWith(CONFIG_FOLDER_NAME + File.separator)) { throw new IllegalArgumentException("File is not located under config folder"); }// www .ja v a2 s .c o m relativePath = relativePath.substring(CONFIG_FOLDER_NAME.length() + File.separator.length()); if (relativePath.contains(File.separator + "..")) { throw new IllegalArgumentException("File contains " + File.separator + ".."); } return relativePath; }
From source file:com.cloudant.sync.datastore.DatastoreTestUtils.java
public static SQLDatabase createDatabase(String database_dir, String database_file) throws IOException, SQLException { String path = database_dir + File.separator + database_file + DATABASE_FILE_EXT; File dbFile = new File(path); FileUtils.touch(dbFile);/* www .jav a2s . c o m*/ SQLDatabase database = SQLDatabaseFactory.openSqlDatabase(dbFile.getAbsolutePath()); SQLDatabaseFactory.updateSchema(database, DatastoreConstants.getSchemaVersion3(), 3); SQLDatabaseFactory.updateSchema(database, DatastoreConstants.getSchemaVersion4(), 4); SQLDatabaseFactory.updateSchema(database, DatastoreConstants.getSchemaVersion5(), 5); return database; }