Example usage for java.io File separatorChar

List of usage examples for java.io File separatorChar

Introduction

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

Prototype

char separatorChar

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

Click Source Link

Document

The system-dependent default name-separator character.

Usage

From source file:Main.java

public static File getLogPath(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File externalStorage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        if (externalStorage == null)
            return null;
        return new File(externalStorage.getPath() + File.separatorChar + "logs");
    }//from www  .j  av a 2 s.com

    return null;
}

From source file:Main.java

public static String dirpart(String name) {
    int s = name.lastIndexOf(File.separatorChar);
    return s == -1 ? null : name.substring(0, s);
}

From source file:Main.java

/**
 * Fixes the file sperator char for the target platform
 * using the following replacement./*from   w  w  w . j  a  v  a 2  s.  c  o  m*/
 * 
 * <ul>
 *  <li> '/' ==>  File.separatorChar
 *  <li> '\\' ==>  File.separatorChar
 * </ul>
 *
 * @param arg the argument to fix
 * @return the transformed argument 
 */
public static String fixFileSeparatorChar(String arg) {
    return arg.replace(SLASH_CHAR, File.separatorChar).replace(BACKSLASH_CHAR, File.separatorChar);
}

From source file:cat.ogasoft.protocolizer.processor.CompilerPhase.java

public static void processCompiler(RoundEnvironment roundEnv) throws CompilerException {
    try {//  w  w  w  .  j a  v a 2  s  .  c om
        String protocPath = "src" + File.separatorChar + "cat" + File.separatorChar + "ogasoft"
                + File.separatorChar + "protocolizer" + File.separatorChar + "protoc";

        DefaultExecutor de = new DefaultExecutor();
        for (Element element : roundEnv.getElementsAnnotatedWith(ProtoFileV2.Compiler.class)) {
            ProtoFileV2.Compiler compiler = element.getAnnotation(ProtoFileV2.Compiler.class);
            if (compiler.compile()) {
                String base = protocPath.replace('.', File.separatorChar);
                File dst = new File(base);
                if (!dst.exists() && !dst.mkdirs()) {
                    throw new Exception("Cann not be created directory " + dst.getAbsolutePath());
                }
                File rootDirectori = new File(base);
                //Compile all the files in compiler.protoFilePaths()
                FileFilter filter = new FileFilter() {
                    @Override
                    public boolean accept(File pathname) {
                        return pathname.getName().toLowerCase().endsWith(".proto");
                    }
                };
                for (File protoc : rootDirectori.listFiles(filter)) {
                    String target = base + File.separatorChar + protoc.getName();
                    LOG.info("\tCompiling " + target + "...");
                    CommandLine cmd = CommandLine.parse(compiler.command() + " --proto_path=" + protocPath + " "
                            + compiler.language().option + "=src " + target);
                    int result = de.execute(cmd);
                    if (result != 0) {
                        throw new CompilerException("HO ho... somthing went wrong, code: " + result);
                    }
                    LOG.info("\t" + target + " compiled");
                }
            }
        }
    } catch (Exception e) {
        //Any exception is a CompilerException.
        throw new CompilerException(e.getMessage());
    }
}

From source file:com.autentia.common.util.ejb.JBossUtils.java

/**
 * Devuelve el nombre del ear en el que se encuentra la clase <code>clazz</code>. "" si no est en un ear.
 * <p>/*from  w w  w. j  av a  2 s  .  c  o m*/
 * Este mtodo esta probado para JBoss 4.2.2GA.
 * 
 * @param clazz clase que se est buscando.
 * @return el nombre del ear en el que se encuentra la clase <code>clazz</code>. "" si no est en un ear.
 */
public static String getEarName(Class<?> clazz) {
    String cn = File.separator + clazz.getCanonicalName();
    cn = cn.replace('.', File.separatorChar);
    cn += ".class";
    final URL url = Thread.currentThread().getContextClassLoader().getResource(cn);
    final String path = url.getPath();
    if (log.isDebugEnabled()) {
        log.debug(clazz.getCanonicalName() + " is in path: " + path);
    }
    final int indexOfEar = path.indexOf(".ear");
    final int indexOfExclamationChar = path.indexOf("!");
    if (indexOfEar > -1 && indexOfExclamationChar > -1 && indexOfEar < indexOfExclamationChar) {
        // JBoss despliega los ear en un directorio temporal del estilo: .../tmp34545nombreDelEar.ear-contents/...
        int beginTempDir = path.lastIndexOf(File.separatorChar, indexOfEar);
        int i = beginTempDir;
        boolean reachedDigit = false;
        while (i < indexOfEar) {
            if (Character.isDigit(path.charAt(i))) {
                reachedDigit = true;
            } else if (reachedDigit) {
                break;
            }
            i++;
        }
        final String prefix = path.substring(i, indexOfEar) + File.separator;
        log.debug(clazz.getCanonicalName() + " is inside ear: " + prefix);
        return prefix;
    }

    log.debug(clazz.getCanonicalName() + " is not inside an ear.");
    return "";
}

From source file:edu.stanford.muse.email.VerifyEmailSetup.java

public static Pair<Boolean, String> run() {
    PrintStream savedOut = System.out;
    InputStream savedIn = System.in;

    try {//from ww  w.  ja  va 2s  .  c  om
        // Get a Properties object
        Properties props = System.getProperties();

        // Get a Session object
        Session session = Session.getInstance(props, null);
        session.setDebug(true);
        String filename = System.getProperty("java.io.tmpdir") + File.separatorChar + "verifyEmailSetup";
        PrintStream ps = new PrintStream(new FileOutputStream(filename));
        System.setOut(ps);
        System.setErr(ps);

        // Get a Store object
        Store store = null;
        store = session.getStore("imaps");
        store.connect("imap.gmail.com", 993, "checkmuse", ""); // not the real password. unfortunately, the checkmuse a/c will get blocked by google.
        //           Folder folder = store.getFolder("[Gmail]/Sent Mail");
        //           int totalMessages = folder.getMessageCount();
        // System.err.println (totalMessages + " messages!");
        ps.close();
        String contents = Util.getFileContents(filename);
        System.out.println(contents);
        return new Pair<Boolean, String>(Boolean.TRUE, contents);
    } catch (AuthenticationFailedException e) {
        /* its ok if auth failed. we only want to check if IMAPS network route is blocked.
         when network is blocked, we'll get something like
        javax.mail.MessagingException: No route to host; 
        nested exception is: 
        java.net.NoRouteToHostException: No route to host 
        ...
        */
        log.info("Verification succeeded: " + Util.stackTrace(e));
        return new Pair<Boolean, String>(Boolean.TRUE, "");
    } catch (Exception e) {
        log.warn("Verification failed: " + Util.stackTrace(e));
        return new Pair<Boolean, String>(Boolean.FALSE, e.toString()); // stack track reveals too much about our code... Util.stackTrace(e));         
    } finally {
        System.setOut(savedOut);
        System.setIn(savedIn);
    }
}

From source file:ezbake.persist.FilePersist.java

public static String joinPath(String... paths) {
    return StringUtils.join(paths, File.separatorChar);
}

From source file:Main.java

public static String prefixWithSeparator(final String s) {
    if (s != null && s.length() > 0) {
        char firstCharacter = s.charAt(0);
        if (firstCharacter != '\\' && firstCharacter != '/') {
            return File.separatorChar + s;
        }/*w  w  w.j a  va2  s .  c  om*/
    }
    return s;
}

From source file:dsd.controller.ParsedInputFilesController.java

public static String FetchStoredPath(eFileType fileType, Calendar date) {
    String pathForTransforming = ParsedInputFilesDAO.FetchStoredPath(fileType, date);
    pathForTransforming = StringUtils.replace(pathForTransforming, "\\", String.valueOf(File.separatorChar));
    pathForTransforming = StringUtils.replace(pathForTransforming, "/", String.valueOf(File.separatorChar));
    return pathForTransforming;
}

From source file:kyotocabinet.Loader.java

/**
 * Load the native library./*from www  .j a  v a  2  s  .  c o m*/
 */
static synchronized void load() {
    if (loaded) {
        return;
    }
    String lib = System.mapLibraryName("jkyotocabinet");
    if (lib.endsWith(".dll")) {
        // lib?lib
        URL url = Loader.class.getClassLoader().getResource(System.mapLibraryName("jkyotocabinet"));
        String libFileName = "./temp" + File.separatorChar + System.mapLibraryName("jkyotocabinet");
        File file = new File(libFileName);
        try {
            FileUtils.copyURLToFile(url, file);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.load(file.getAbsolutePath());
    } else {
        System.loadLibrary("jkyotocabinet");
    }
    loaded = true;
}