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 getOutputFolder(String appName) {
    String path = getAppFolder(appName) + File.separator + OUTPUT_FOLDER_NAME;
    return path;
}

From source file:asia.gkc.vneedu.utils.FileUtil.java

/**
 * //from  w  w w. ja  v a2s  .  c o  m
 *
 * @param dir - 
 * @return 
 */
public static boolean buildDir(String dir) {
    if (dir.endsWith(File.separator))
        return buildDir(new File(dir));
    String path = dir.substring(0, dir.lastIndexOf(File.separator));

    return buildDir(new File(path));
}

From source file:Main.java

public static String getTableDefinitionCsvFile(String appName, String tableId) {
    return getTablesFolder(appName, tableId) + File.separator + DEFINITION_CSV;
}

From source file:Main.java

public static String getTablePropertiesCsvFile(String appName, String tableId) {
    return getTablesFolder(appName, tableId) + File.separator + PROPERTIES_CSV;
}

From source file:fedora.server.security.servletfilters.xmluserfile.FedoraUsers.java

private static File getFedoraUsersXML() {
    String homeConfig = FEDORA_HOME + File.separator + "server" + File.separator + "config" + File.separator
            + "fedora-users.xml";
    String testConfig = "src/main/resources/fcfg/server/fedora-users.xml";
    fedoraUsersXML = new File(homeConfig);
    if (!fedoraUsersXML.exists()) {
        fedoraUsersXML = new File(testConfig);
    }/*from   ww w  . jav  a  2 s .c  om*/
    return fedoraUsersXML;
}

From source file:Main.java

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

From source file:com.orange.ocara.tools.AssetsHelper.java

/**
 * Copy the asset at the specified path to this app's data directory. If the
 * asset is a directory, its contents are also copied.
 *///w  ww.j ava 2s. c om
public static void copyAsset(AssetManager assetManager, String rootPath, String path, File targetFolder)
        throws IOException {

    String fullPath = StringUtils.isEmpty(path) ? rootPath : rootPath + File.separator + path;

    // If we have a directory, we make it and recurse. If a file, we copy its
    // contents.
    try {
        String[] contents = assetManager.list(fullPath);

        // The documentation suggests that list throws an IOException, but doesn't
        // say under what conditions. It'd be nice if it did so when the path was
        // to a file. That doesn't appear to be the case. If the returned array is
        // null or has 0 length, we assume the path is to a file. This means empty
        // directories will get turned into files.
        if (contents == null || contents.length == 0) {
            throw new IOException();
        }

        // Recurse on the contents.
        for (String entry : contents) {
            String newPath = StringUtils.isEmpty(path) ? entry : path + File.separator + entry;

            copyAsset(assetManager, rootPath, newPath, targetFolder);
        }
    } catch (IOException e) {

        File file = new File(targetFolder, path);

        if (file.getParentFile() != null) {
            file.getParentFile().mkdirs();
        }

        FileUtils.copyInputStreamToFile(assetManager.open(fullPath), file);
    }
}

From source file:captor.app.CaptorOptionsParser.java

protected static String getDefaultInstallPath() {
    String[] installPathnames = new String[2];
    File installPath = null;/*from  ww w  .  j av  a 2  s  . co m*/

    installPathnames[0] = System.getenv("CAPTOR_HOME");
    installPathnames[1] = System.getProperty("user.dir") + File.separator + "..";

    for (String path : installPathnames) {
        if (path != null) {
            installPath = new File(path);
            if (installPath.exists() && installPath.isDirectory()) {
                break;
            } else {
                installPath = null;
            }
        }
    }

    try {
        return installPath.getCanonicalPath();
    } catch (IOException e) {
    }
    return null;
}

From source file:Main.java

public static File getOutputMediaFile() {

    // External sdcard location

    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
            IMAGE_DIRECTORY_NAME);/*  w  ww  . j a va 2s . c  o  m*/
    // Create the storage directory if it does not exist
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create " + IMAGE_DIRECTORY_NAME + " directory");
            return null;
        }
    }

    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
    File mediaFile;

    mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");

    return mediaFile;
}

From source file:Main.java

/** Create a File for saving an image or video */
public static File getOutputMediaFile() {
    // To be safe, you should check that the SDCard is mounted
    // using Environment.getExternalStorageState() before doing this.

    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), APPDIR);
    // This location works best if you want the created images to be shared
    // between applications and persist after your app has been uninstalled.

    // Create the storage directory if it does not exist

    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(APPDIR, "failed to create directory");
            return null;
        }// ww w. j av  a  2 s . c o  m
    }

    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;
    mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
    return mediaFile;
}