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:com.granita.contacticloudsync.log.ExternalFileLogger.java

public ExternalFileLogger(Context context, String fileName, boolean verbose) throws IOException {
    this.verbose = verbose;

    File dir = getDirectory(context);
    if (dir == null)
        throw new IOException("External media not available for log creation");

    name = StringUtils.remove(StringUtils.remove(fileName, File.pathSeparatorChar), File.separatorChar);

    File log = new File(dir, name);
    writer = new PrintWriter(log);
}

From source file:com.ansorgit.plugins.bash.util.SystemPathUtil.java

@Nullable
public static String findExecutable(@NotNull String commandName, String path) {
    String fullPath = path + File.separatorChar + commandName;
    File command = new File(fullPath);
    return command.exists() ? command.getAbsolutePath() : null;
}

From source file:edu.stanford.muse.webapp.GroupsConfig.java

/** loads session with the given name, and puts it into the given http session. returns true if it succeeded */
public static boolean load(HttpSession session, String title) {
    boolean success = true;
    String cacheDir = (String) JSPHelper.getSessionAttribute(session, "cacheDir");
    Archive archive = JSPHelper.getArchive(session);
    String filename = "";
    if (cacheDir == null) {
        cacheDir = DEFAULT_CACHE_DIR;/*from  w  ww  .ja  va  2s .c  om*/
        session.setAttribute("cacheDir", cacheDir);
    }

    filename = cacheDir + File.separatorChar + title + GROUPING_SUFFIX;
    if (!new File(filename).exists())
        return false;

    JSPHelper.log.info("Loading grouping from " + filename);

    // keep reading till eof exception
    try {
        GroupAssigner ga = (GroupAssigner) Util.readObjectFromFile(filename);
        archive.setGroupAssigner(ga);
    } catch (Exception e) {
        JSPHelper.log.warn("Warning unable to load groups: " + Util.stackTrace(e));
        success = false;
    }

    return success;
}

From source file:eu.scape_project.hawarp.utils.StringUtils.java

public static String ensureTrailSep(String path) {
    if (path.charAt(path.length() - 1) != File.separatorChar) {
        path += File.separator;/*  w w w  .jav a  2 s . c o  m*/
    }
    return path;
}

From source file:com.appleframework.jmx.core.util.CoreUtils.java

public static String getConnectorDir() {
    return getRootDir() + File.separatorChar + "connector";
}

From source file:com.us.util.FileHelper.java

public static File getClassFile(String root, String className) {
    String path = className.replace(".", File.separatorChar + "");
    return getFile(root, path);
}

From source file:org.apache.s4.client.Adapter.java

@SuppressWarnings("static-access")
public static void main(String args[]) throws IOException, InterruptedException {

    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("corehome").hasArg().withDescription("core home").create("c"));

    options.addOption(/*from   w ww .j  a v a 2s. c  o  m*/
            OptionBuilder.withArgName("instanceid").hasArg().withDescription("instance id").create("i"));

    options.addOption(
            OptionBuilder.withArgName("configtype").hasArg().withDescription("configuration type").create("t"));

    options.addOption(OptionBuilder.withArgName("userconfig").hasArg()
            .withDescription("user-defined legacy data adapter configuration file").create("d"));

    CommandLineParser parser = new GnuParser();
    CommandLine commandLine = null;

    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException pe) {
        System.err.println(pe.getLocalizedMessage());
        System.exit(1);
    }

    int instanceId = -1;
    if (commandLine.hasOption("i")) {
        String instanceIdStr = commandLine.getOptionValue("i");
        try {
            instanceId = Integer.parseInt(instanceIdStr);
        } catch (NumberFormatException nfe) {
            System.err.println("Bad instance id: %s" + instanceIdStr);
            System.exit(1);
        }
    }

    if (commandLine.hasOption("c")) {
        coreHome = commandLine.getOptionValue("c");
    }

    String configType = "typical";
    if (commandLine.hasOption("t")) {
        configType = commandLine.getOptionValue("t");
    }

    String userConfigFilename = null;
    if (commandLine.hasOption("d")) {
        userConfigFilename = commandLine.getOptionValue("d");
    }

    File userConfigFile = new File(userConfigFilename);
    if (!userConfigFile.isFile()) {
        System.err.println("Bad user configuration file: " + userConfigFilename);
        System.exit(1);
    }

    File coreHomeFile = new File(coreHome);
    if (!coreHomeFile.isDirectory()) {
        System.err.println("Bad core home: " + coreHome);
        System.exit(1);
    }

    if (instanceId > -1) {
        System.setProperty("instanceId", "" + instanceId);
    } else {
        System.setProperty("instanceId", "" + S4Util.getPID());
    }

    String configBase = coreHome + File.separatorChar + "conf" + File.separatorChar + configType;
    String configPath = configBase + File.separatorChar + "client-adapter-conf.xml";
    File configFile = new File(configPath);
    if (!configFile.exists()) {
        System.err.printf("adapter config file %s does not exist\n", configPath);
        System.exit(1);
    }

    // load adapter config xml
    ApplicationContext coreContext;
    coreContext = new FileSystemXmlApplicationContext("file:" + configPath);
    ApplicationContext context = coreContext;

    Adapter adapter = (Adapter) context.getBean("client_adapter");

    ApplicationContext appContext = new FileSystemXmlApplicationContext(
            new String[] { "file:" + userConfigFilename }, context);

    Map<?, ?> inputStubBeanMap = appContext.getBeansOfType(InputStub.class);
    Map<?, ?> outputStubBeanMap = appContext.getBeansOfType(OutputStub.class);

    if (inputStubBeanMap.size() == 0 && outputStubBeanMap.size() == 0) {
        System.err.println("No user-defined input/output stub beans");
        System.exit(1);
    }

    ArrayList<InputStub> inputStubs = new ArrayList<InputStub>(inputStubBeanMap.size());
    ArrayList<OutputStub> outputStubs = new ArrayList<OutputStub>(outputStubBeanMap.size());

    // add all input stubs
    for (Map.Entry<?, ?> e : inputStubBeanMap.entrySet()) {
        String beanName = (String) e.getKey();
        System.out.println("Adding InputStub " + beanName);
        inputStubs.add((InputStub) e.getValue());
    }

    // add all output stubs
    for (Map.Entry<?, ?> e : outputStubBeanMap.entrySet()) {
        String beanName = (String) e.getKey();
        System.out.println("Adding OutputStub " + beanName);
        outputStubs.add((OutputStub) e.getValue());
    }

    adapter.setInputStubs(inputStubs);
    adapter.setOutputStubs(outputStubs);

}

From source file:info.mikaelsvensson.devtools.common.PathUtils.java

private static String fixPath(final File source) {
    String fixed = source.getAbsolutePath();
    if (File.separatorChar != SEP) {
        fixed = fixed.replace(File.separatorChar, SEP);
    }/*w  w  w  . j  a v  a  2 s.  co  m*/
    return source.isDirectory() ? trailingSlash(fixed) : fixed;
}

From source file:com.intellij.coldFusion.mxunit.CfmlUnitRemoteTestsRunner.java

public static String getLauncherText(String resourcePath) {
    try {/*from   w  ww.ja va 2s . c  o m*/
        return ResourceUtil.loadText(CfmlUnitRunConfiguration.class.getResource(resourcePath)).replaceFirst(
                "\\Q/*system_delimiter*/\\E", ("" + File.separatorChar).replace("\\", "\\\\\\\\"));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

/**
 * Convert from a <code>URL</code> to a <code>File</code>.
 * <p/>/*from w  ww .j av  a 2 s .  c om*/
 * From version 1.1 this method will decode the URL.
 * Syntax such as <code>file:///my%20docs/file.txt</code> will be
 * correctly decoded to <code>/my docs/file.txt</code>. Starting with version
 * 1.5, this method uses UTF-8 to decode percent-encoded octets to characters.
 * Additionally, malformed percent-encoded octets are handled leniently by
 * passing them through literally.
 *
 * @param url the file URL to convert, {@code null} returns {@code null}
 * @return the equivalent <code>File</code> object, or {@code null}
 * if the URL's protocol is not <code>file</code>
 */
public static File toFile(URL url) {
    if (url == null || !"file".equalsIgnoreCase(url.getProtocol())) {
        return null;
    } else {
        String filename = url.getFile().replace('/', File.separatorChar);
        filename = decodeUrl(filename);
        return new File(filename);
    }
}