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 formatToUrlNoPrefix(String filePath) {
    if (filePath == null) {
        return null;
    }//w ww. jav  a  2  s .  c  o  m
    filePath = formatToUrl(filePath);
    if (File.separator.endsWith("/")) {
        filePath = filePath.substring("file://".length());
    } else {
        filePath = filePath.substring("file:///".length());
    }
    return filePath;
}

From source file:Main.java

public static void cleanDatabases(Context context) {
    deleteFilesByDirectory(new File(
            context.getFilesDir().getPath() + context.getPackageName() + File.separator + "databases"));
}

From source file:Main.java

/***
 * delete all logs/*ww w.j  a  va  2 s  .  c o m*/
 */
public static void deleteAllFiles() {
    File directory = new File(Environment.getExternalStorageDirectory() + File.separator + folderName);
    if (directory.exists()) {
        for (File file : directory.listFiles())
            file.delete();
    }
}

From source file:Main.java

public static String getTotalSkinPath(Context context) {
    String SKIN_PATH = context.getCacheDir().getAbsolutePath();
    String totalPath = SKIN_PATH + File.separator + SKIN_NAME;
    return totalPath;
}

From source file:Main.java

public static void cleanSharedPreference(Context context) {
    deleteFilesByDirectory(new File(
            context.getFilesDir().getPath() + context.getPackageName() + File.separator + "shared_prefs"));
}

From source file:Main.java

private static String formatPathWithPathElements(String[] dirs) {
    String path = "";
    boolean first = true;
    for (String dir : dirs) {
        if (first) {
            first = false;// w  w w .ja  v a 2s  .  c  o  m
        } else {
            path += File.separator;
        }
        path += dir;
    }
    return path;
}

From source file:Main.java

public static File createFileInSDCard(String fileName, String dir) {
    File file = new File(SDCardRoot + dir + File.separator + fileName);
    try {/*from  w  w w.  j a v a2  s.  c o  m*/
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    updateFile = file;
    return file;
}

From source file:Main.java

public static void WriteTxtFile(Context context, String strcontent) {

    String strContent = strcontent + "\n";
    try {/*from w  w  w  .ja  v a2 s  .  co  m*/
        File file = new File(context.getCacheDir() + File.separator + "wanjia.txt");
        if (!file.exists()) {
            file.createNewFile();
        }
        RandomAccessFile raf = new RandomAccessFile(file, "rw");
        raf.seek(file.length());
        raf.write(strContent.getBytes());
        raf.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static String getAppDirectoryString() {
    return Environment.getExternalStorageDirectory().getPath() + File.separator + "LocalMangaViewer"
            + File.separator;/*from w  ww . j a  va  2 s  . co  m*/
}

From source file:Main.java

public static int fileSize(String dir, String fileName) {
    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");
    }// w  w  w .j a v a  2 s.c  o  m
    return ((int) inFile.length());
}