Example usage for java.io File separator

List of usage examples for java.io File separator

Introduction

In this page you can find the example usage for java.io File separator.

Prototype

String separator

To view the source code for java.io File separator.

Click Source Link

Document

The system-dependent default name-separator character, represented as a string for convenience.

Usage

From source file:Main.java

public static String getInstrumentalDirectory() {
    return Environment.getExternalStorageDirectory() + File.separator + "MicDroid" + File.separator
            + "instrumental";
}

From source file:mesclasses.util.EleveFileUtil.java

public static File getEleveDir(Eleve eleve) {
    return new File(
            FileConfigurationManager.getInstance().getUploadDir() + File.separator + sanitize(eleve.getId()));
}

From source file:Main.java

public static String getSdCardRootPath() {
    return Environment.getExternalStorageDirectory().getAbsolutePath().replace("/mnt", "") + File.separator;
}

From source file:Main.java

/**
 * Get folder name from the path/*w  w  w  .ja  v  a2s.c  o m*/
 * 
 * @param filePath
 *            The path of the file
 * @return String The folder path
 * @see <pre>
 *      getFolderName(null)               =   null
 *      getFolderName("")                 =   ""
 *      getFolderName("   ")              =   ""
 *      getFolderName("a.mp3")            =   ""
 *      getFolderName("a.b.rmvb")         =   ""
 *      getFolderName("abc")              =   ""
 *      getFolderName("/home/admin")      =   "/home"
 *      getFolderName("/home/admin/a.txt/b.mp3")  =   "/home/admin/a.txt"
 * </pre>
 */
public static String getFolderName(String filePath) {

    if (TextUtils.isEmpty(filePath)) {
        return filePath;
    }

    int filePosi = filePath.lastIndexOf(File.separator);
    if (filePosi == -1) {
        return "";
    }
    return filePath.substring(0, filePosi);
}

From source file:Main.java

public static String subFileName(String inCertPath) {
    if (null == inCertPath) {
        return null;
    }// ww w. j  a va 2  s.  c  om
    int index = inCertPath.lastIndexOf(File.separator);
    if (index < 0) {
        return inCertPath;
    }
    return inCertPath.substring(index + 1);
}

From source file:dao.EntryDaoTest.java

@BeforeClass
public static void setUpClass() {
    String fSeparator = File.separator;
    try {//from  ww w.j  a v  a2  s .c  o m
        File folder = new File(
                System.getProperty("user.dir") + fSeparator + "MyDiaryBook" + fSeparator + "Users" + fSeparator
                        + "Panagiwtis Georgiadis" + fSeparator + "Entries" + fSeparator + "Texnologia2");
        folder.mkdirs();

        File textFolder = new File(folder.toString() + fSeparator + "Texts");
        textFolder.mkdirs();
        File textFile = new File(textFolder.toString() + fSeparator + "test.txt");
        BufferedWriter bw;
        FileWriter fw;
        fw = new FileWriter(textFile, true);
        bw = new BufferedWriter(fw);
        bw.write("test0123456789");
        if (bw != null)
            bw.close();
        fw.close();
        File imageFolder = new File(folder.toString() + fSeparator + "Images");
        imageFolder.mkdirs();
        String imageSourcePath = System.getProperty("user.dir") + fSeparator + "src" + fSeparator + "test"
                + fSeparator + "java" + fSeparator + "resources" + fSeparator + "testImg.jpg";
        File imageSourceFile = new File(imageSourcePath);
        FileUtils.copyFileToDirectory(imageSourceFile, imageFolder);

        String videoSourcePath = System.getProperty("user.dir") + fSeparator + "src" + fSeparator + "test"
                + fSeparator + "java" + fSeparator + "resources" + fSeparator + "testVideo.mp4";
        File videoSourceFile = new File(videoSourcePath);
        File videoFolder = new File(folder.toString() + fSeparator + "Videos");
        videoFolder.mkdirs();
        FileUtils.copyFileToDirectory(videoSourceFile, videoFolder);
    } catch (IOException ex) {
        Logger.getLogger(EntryDaoTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Main.java

public static boolean isFileAncestorOf(String parentPath, String childPath) {
    if (!parentPath.endsWith(File.separator)) {
        parentPath += File.separator;
    }//w  w  w  .  j ava2  s .  c  om
    if (!childPath.endsWith(File.separator)) {
        childPath += File.separator;
    }
    return childPath.startsWith(parentPath);
}

From source file:Main.java

/**
 * Get file name from the path (with extension)
 * /*from   w w w .ja  v  a 2 s .  c  o  m*/
 * @param filePath
 *            The path of the file
 * @return String File name with extension
 * @see <pre>
 *      getFileName(null)               =   null
 *      getFileName("")                 =   ""
 *      getFileName("   ")              =   "   "
 *      getFileName("a.mp3")            =   "a.mp3"
 *      getFileName("a.b.rmvb")         =   "a.b.rmvb"
 *      getFileName("abc")              =   "abc"
 *      getFileName("/home/admin")      =   "admin"
 *      getFileName("/home/admin/a.txt/b.mp3")  =   "b.mp3"
 * </pre>
 */
public static String getFileName(String filePath) {
    if (TextUtils.isEmpty(filePath)) {
        return filePath;
    }

    int filePosi = filePath.lastIndexOf(File.separator);
    if (filePosi == -1) {
        return filePath;
    }
    return filePath.substring(filePosi + 1);
}

From source file:Main.java

public static String getConfigFolder(String appName) {
    String path = getAppFolder(appName) + File.separator + CONFIG_FOLDER_NAME;
    return path;
}

From source file:Main.java

public static String getLoggingFolder(String appName) {
    String path = getAppFolder(appName) + File.separator + LOGGING_FOLDER_NAME;
    return path;
}