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.redhat.red.offliner.ftest.MavenMetadataGenerateFTest.java

/**
 * In general, we should only have one test method per functional test. This allows for the best parallelism when we
 * execute the tests, especially if the setup takes some time.
 *
 * @throws Exception In case anything (anything at all) goes wrong!
 *//*w ww  . j  a  v a2s  . c o m*/
@Test
public void run() throws Exception {
    // We only need one repo server.
    TestRepositoryServer server = newRepositoryServer();

    // Generate some test content
    byte[] content = contentGenerator.newBinaryContent(1024);

    Dependency dep = contentGenerator.newDependency();
    Model pom = contentGenerator.newPom();
    pom.addDependency(dep);

    String path = contentGenerator.pathOf(dep);

    // Register the generated content by writing it to the path within the repo server's dir structure.
    // This way when the path is requested it can be downloaded instead of returning a 404.
    server.registerContent(path, content);
    server.registerContent(path + Main.SHA_SUFFIX, sha1Hex(content));
    server.registerContent(path + Main.MD5_SUFFIX, md5Hex(content));

    // All deps imply an accompanying POM file when using the POM artifact list reader, so we have to register one of these too.
    Model pomDep = contentGenerator.newPomFor(dep);
    String pomPath = contentGenerator.pathOf(pomDep);
    String md5Path = pomPath + Main.MD5_SUFFIX;
    String shaPath = pomPath + Main.SHA_SUFFIX;

    String pomStr = contentGenerator.pomToString(pomDep);

    server.registerContent(pomPath, pomStr);
    server.registerContent(md5Path, md5Hex(pomStr));
    server.registerContent(shaPath, sha1Hex(pomStr));

    // Write the plaintext file we'll use as input.
    File pomFile = temporaryFolder.newFile(getClass().getSimpleName() + ".pom");

    FileUtils.write(pomFile, contentGenerator.pomToString(pom));

    Options opts = new Options();
    opts.setBaseUrls(Collections.singletonList(server.getBaseUri()));

    // Capture the downloads here so we can verify the content.
    File downloads = temporaryFolder.newFolder();

    opts.setDownloads(downloads);
    opts.setLocations(Collections.singletonList(pomFile.getAbsolutePath()));

    // run `new Main(opts).run()` and return the Main instance so we can query it for errors, etc.
    Main finishedMain = run(opts);
    assertThat("Errors should be empty!", finishedMain.getErrors().isEmpty(), equalTo(true));

    // get the ProjectVersion info by pomPath reading from ArtifactPathInfo parse.
    ArtifactPathInfo artifactPathInfo = ArtifactPathInfo.parse(pomPath);
    ProjectVersionRef gav = artifactPathInfo.getProjectId();
    File metadataFile = Paths.get(opts.getDownloads().getAbsolutePath(),
            gav.getGroupId().replace('.', File.separatorChar), gav.getArtifactId(), "maven-metadata.xml")
            .toFile();
    assertThat("maven-metadata.xml for path: " + metadataFile.getParent()
            + " doesn't seem to have been generated!", metadataFile.exists(), equalTo(true));
}

From source file:filterviewplugin.FilterViewSettings.java

public Icon getFilterIcon(ProgramFilter filter) {
    if (!mIconCache.containsKey(filter)) {
        String fileName = getFilterIconName(filter);
        if (!StringUtils.isEmpty(fileName)) {
            mIconCache.put(filter, new ImageIcon(getIconDirectoryName() + File.separatorChar + fileName));
        } else {/* w  w w .ja  v  a  2s.com*/
            mIconCache.put(filter, null);
        }
    }
    return mIconCache.get(filter);
}

From source file:org.apache.sling.event.it.AbstractJobHandlingTest.java

@Configuration
public Option[] config() {
    final String buildDir = System.getProperty(SYS_PROP_BUILD_DIR, DEFAULT_BUILD_DIR);
    final String bundleFileName = System.getProperty(BUNDLE_JAR_SYS_PROP);
    final File bundleFile = new File(bundleFileName);
    if (!bundleFile.canRead()) {
        throw new IllegalArgumentException("Cannot read from bundle file " + bundleFileName
                + " specified in the " + BUNDLE_JAR_SYS_PROP + " system property");
    }/*from   www.j  a va 2  s  .  c  o  m*/

    String localRepo = System.getProperty("maven.repo.local", "");

    final String jackrabbitVersion = "2.13.1";
    final String oakVersion = "1.5.7";

    final String slingHome = new File(buildDir + File.separatorChar + "sling_" + System.currentTimeMillis())
            .getAbsolutePath();

    return options(frameworkProperty("sling.home").value(slingHome),
            frameworkProperty("repository.home").value(slingHome + File.separatorChar + "repository"),
            when(localRepo.length() > 0)
                    .useOptions(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)),
            when(System.getProperty(PORT_CONFIG) != null)
                    .useOptions(systemProperty(PORT_CONFIG).value(System.getProperty(PORT_CONFIG))),
            systemProperty("pax.exam.osgi.unresolved.fail").value("true"),

            ConfigurationAdminOptions.newConfiguration("org.apache.felix.jaas.ConfigurationSpi").create(true)
                    .put("jaas.defaultRealmName", "jackrabbit.oak")
                    .put("jaas.configProviderName", "FelixJaasProvider").asOption(),
            ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
                    .create(true).put("jaas.controlFlag", "optional")
                    .put("jaas.classname",
                            "org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule")
                    .put("jaas.ranking", 300).asOption(),
            ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
                    .create(true).put("jaas.controlFlag", "required")
                    .put("jaas.classname",
                            "org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl")
                    .asOption(),
            ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
                    .create(true).put("jaas.controlFlag", "sufficient")
                    .put("jaas.classname",
                            "org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule")
                    .put("jaas.ranking", 200).asOption(),
            ConfigurationAdminOptions
                    .newConfiguration(
                            "org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl")
                    .create(true)
                    .put("org.apache.jackrabbit.oak.authentication.configSpiName", "FelixJaasProvider")
                    .asOption(),
            ConfigurationAdminOptions
                    .newConfiguration("org.apache.jackrabbit.oak.security.user.UserConfigurationImpl")
                    .create(true).put("groupsPath", "/home/groups").put("usersPath", "/home/users")
                    .put("defaultPath", "1").put("importBehavior", "besteffort").asOption(),
            ConfigurationAdminOptions
                    .newConfiguration("org.apache.jackrabbit.oak.security.user.RandomAuthorizableNodeName")
                    .create(true)
                    .put("enabledActions",
                            new String[] {
                                    "org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction" })
                    .put("userPrivilegeNames", new String[] { "jcr:all" })
                    .put("groupPrivilegeNames", new String[] { "jcr:read" }).asOption(),
            ConfigurationAdminOptions.newConfiguration(
                    "org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider")
                    .create(true).put("length", 21).asOption(),
            ConfigurationAdminOptions
                    .newConfiguration("org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService")
                    .create(true).put("name", "Default NodeStore").asOption(),

            // logging
            systemProperty("pax.exam.logging").value("none"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"),
            mavenBundle("org.slf4j", "slf4j-api", "1.7.13"),
            mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.13"),
            mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.13"),

            mavenBundle("commons-io", "commons-io", "2.4"),
            mavenBundle("commons-fileupload", "commons-fileupload", "1.3.1"),
            mavenBundle("commons-collections", "commons-collections", "3.2.2"),
            mavenBundle("commons-codec", "commons-codec", "1.10"),
            mavenBundle("commons-lang", "commons-lang", "2.6"),
            mavenBundle("commons-pool", "commons-pool", "1.6"),

            mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.concurrent", "1.3.4_1"),

            mavenBundle("org.apache.geronimo.bundles", "commons-httpclient", "3.1_1"),
            mavenBundle("org.apache.tika", "tika-core", "1.9"),
            mavenBundle("org.apache.tika", "tika-bundle", "1.9"),

            // infrastructure
            mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2"),
            mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "3.1.6"),
            mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.4.4"),
            mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.0.4"),
            mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.10"),
            mavenBundle("org.apache.felix", "org.apache.felix.inventory", "1.0.4"),
            mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.1.2"),

            // sling
            mavenBundle("org.apache.sling", "org.apache.sling.settings", "1.3.8"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi", "2.3.0"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.json", "2.0.16"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.mime", "2.1.8"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.classloader", "1.3.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.scheduler", "2.4.14"),
            mavenBundle("org.apache.sling", "org.apache.sling.commons.threads", "3.2.4"),

            mavenBundle("org.apache.sling", "org.apache.sling.auth.core", "1.3.12"),
            mavenBundle("org.apache.sling", "org.apache.sling.discovery.api", "1.0.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.discovery.commons", "1.0.12"),
            mavenBundle("org.apache.sling", "org.apache.sling.discovery.standalone", "1.0.2"),

            mavenBundle("org.apache.sling", "org.apache.sling.api", "2.14.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.resourceresolver", "1.4.18"),
            mavenBundle("org.apache.sling", "org.apache.sling.adapter", "2.1.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource", "2.8.0"),
            mavenBundle("org.apache.sling", "org.apache.sling.jcr.classloader", "3.2.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.jcr.contentloader", "2.1.8"),
            mavenBundle("org.apache.sling", "org.apache.sling.engine", "2.6.2"),
            mavenBundle("org.apache.sling", "org.apache.sling.serviceusermapper", "1.2.2"),

            mavenBundle("org.apache.sling", "org.apache.sling.jcr.jcr-wrapper", "2.0.0"),
            mavenBundle("org.apache.sling", "org.apache.sling.jcr.api", "2.4.0"),
            mavenBundle("org.apache.sling", "org.apache.sling.jcr.base", "2.4.0"),

            mavenBundle("com.google.guava", "guava", "15.0"),
            mavenBundle("org.apache.jackrabbit", "jackrabbit-api", jackrabbitVersion),
            mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", jackrabbitVersion),
            mavenBundle("org.apache.jackrabbit", "jackrabbit-spi", jackrabbitVersion),
            mavenBundle("org.apache.jackrabbit", "jackrabbit-spi-commons", jackrabbitVersion),
            mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-rmi", jackrabbitVersion),

            mavenBundle("org.apache.felix", "org.apache.felix.jaas", "0.0.4"),

            mavenBundle("org.apache.jackrabbit", "oak-core", oakVersion),
            mavenBundle("org.apache.jackrabbit", "oak-commons", oakVersion),
            mavenBundle("org.apache.jackrabbit", "oak-lucene", oakVersion),
            mavenBundle("org.apache.jackrabbit", "oak-blob", oakVersion),
            mavenBundle("org.apache.jackrabbit", "oak-jcr", oakVersion),

            mavenBundle("org.apache.jackrabbit", "oak-segment", oakVersion),

            mavenBundle("org.apache.sling", "org.apache.sling.jcr.oak.server", "1.1.0"),

            mavenBundle("org.apache.sling", "org.apache.sling.testing.tools", "1.0.6"),
            mavenBundle("org.apache.httpcomponents", "httpcore-osgi", "4.1.2"),
            mavenBundle("org.apache.httpcomponents", "httpclient-osgi", "4.1.2"),

            // SLING-5560: delaying start of the sling.event bundle to
            // ensure the parameter 'startup.delay' is properly set to 1sec
            // for these ITs - as otherwise, the default of 30sec applies -
            // which will cause the tests to fail
            // @see setup() where the bundle is finally started - after reconfig
            CoreOptions.bundle(bundleFile.toURI().toString()).start(false),

            junitBundles());
}

From source file:com.rogue.simpleclient.SimpleClient.java

/**
 * Constructs and authenticates a new client instance. Will ask for input
 * from a supplied {@link Scanner} source.
 *
 * @since 1.0.0/*w w  w .  j a va  2  s .co  m*/
 * @version 1.0.0
 *
 * @param version The minecraft version to use
 * @param username The username/email to authenticate with
 * @param password The password to authenticate with
 * @param appData The location of the application data folder containing MC
 * @throws IOException Any type of communications failure with Mojang
 */
public SimpleClient(String version, String username, String password, File appData) throws IOException {
    this.version = version;
    this.appData = appData;
    this.minecraftDir = new File(this.appData.getAbsoluteFile(), ".minecraft" + File.separatorChar);
    this.gameDir = new File(minecraftDir, "versions" + File.separator + this.version + File.separatorChar);
    this.natives = new File(gameDir, "natives" + File.separatorChar);
    this.connect(username, password);
}

From source file:gmgen.util.MiscUtilities.java

/**
 *  Returns the parent of the specified path.
 *
 *@param  path  The path name/*from  w w  w .  jav a  2  s  .  com*/
 *@return       The parentOfPath value
 *@since        GMGen 3.3
 */
public static String getParentOfPath(String path) {
    // ignore last character of path to properly handle
    // paths like /foo/bar/
    int count = Math.max(0, path.length() - 2);
    int index = path.lastIndexOf(File.separatorChar, count);

    if (index == -1) {
        index = path.lastIndexOf('/', count);
    }

    if (index == -1) {
        // this ensures that getFileParent("protocol:"), for
        // example, is "protocol:" and not "".
        index = path.lastIndexOf(':');
    }

    return path.substring(0, index + 1);
}

From source file:com.openvcx.webcall.ConferenceCreateServlet.java

/**
 * <i>javax.Servlet</i> overridden initializer method
 *//*ww  w  . ja va  2 s  .c om*/
@Override
public void init(ServletConfig c) throws ServletException {
    logger.debug("init start");
    super.init(c);

    try {

        //
        // Load the config file defined in web.xml 'sip-ngconference.conf'
        //
        String configFilePath = getServletContext().getInitParameter("config");
        m_config = new Configuration(configFilePath);

        m_confDefDir = m_config.getString(CONFIG_CONFERENCE_DEF, CONFERNCE_CONFIG_DIR);
        if (m_confDefDir.charAt(m_confDefDir.length() - 1) != File.separatorChar) {
            m_confDefDir += File.separatorChar;
        }
        m_confDefDirAuto = m_confDefDir + "auto/";

        m_tempDir = m_config.getString(CONFIG_CONFERENCE_TEMP_DIR, CONFERENCE_TEMP_DIR);
        if (m_tempDir.charAt(m_tempDir.length() - 1) != File.separatorChar) {
            m_tempDir += File.separatorChar;
        }

        if (null == (m_mediaPortalAddress = m_config.getString(CONFIG_MEDIAPORTAL_LISTENER_ADDRESS, null))) {
            // Try to lookup the legacy naming convention if the user has somehow retained
            // an old sip-ngconference.conf
            m_mediaPortalAddress = m_config.getString(CONFIG_MEDIAPORTAL_LISTENER_ADDRESS_LEGACY, null);
        }
        m_bAutoProvision = m_config.getBoolean(CONFIG_CONFERENCE_PROVISION_AUTO, m_bAutoProvision);

        logger.info("confDefDirAuto: '" + m_confDefDirAuto + "', tempDir: '" + m_tempDir + "', mediaPortal: '"
                + m_mediaPortalAddress + ", provision.auto: " + m_bAutoProvision);

        m_rand = new SecureRandom();

    } catch (Exception e) {
        LogUtil.printError(logger, "init: ", e);
        throw new ServletException(e);
    }

    logger.debug("init done");

}

From source file:com.netspective.commons.io.UriAddressableUniqueFileLocator.java

/**
 * Creates a new file resource locator that will use the specified directory
 * as the base directory for loading templates.
 *
 * @param baseDir the base directory for loading templates
 *//*from  w  w w  .  j a v a 2  s .  co m*/
public UriAddressableUniqueFileLocator(final String rootUrl, final File baseDir, final boolean cacheLocations)
        throws IOException {
    this.rootUrl = rootUrl;
    this.cacheLocations = cacheLocations;
    try {
        Object[] retval = (Object[]) AccessController.doPrivileged(new PrivilegedExceptionAction() {
            public Object run() throws IOException {
                if (!baseDir.exists()) {
                    throw new FileNotFoundException(baseDir + " does not exist.");
                }
                if (!baseDir.isDirectory()) {
                    throw new IOException(baseDir + " is not a directory.");
                }
                Object[] retval = new Object[2];
                retval[0] = baseDir.getCanonicalFile();
                retval[1] = ((File) retval[0]).getPath() + File.separatorChar;
                return retval;
            }
        });
        this.baseDir = (File) retval[0];
        this.canonicalPath = (String) retval[1];
    } catch (PrivilegedActionException e) {
        throw (IOException) e.getException();
    }
}

From source file:com.commander4j.db.JDBPrinters.java

public String getExportRealPath() {
    String result = getExportPath();
    result = result.replace("{base_dir}", Common.base_dir);
    result = StringUtils.replaceChars(result, "\\", String.valueOf(File.separatorChar));
    result = StringUtils.replaceChars(result, "/", String.valueOf(File.separatorChar));
    logger.debug(result);/*from ww w .j  av  a2  s .c o  m*/
    return result;
}

From source file:com.redhat.red.offliner.ftest.SkipMavenMetadataGenerateFTest.java

/**
 * In general, we should only have one test method per functional test. This allows for the best parallelism when we
 * execute the tests, especially if the setup takes some time.
 *
 * @throws Exception In case anything (anything at all) goes wrong!
 *//*from w w w  .  j a va  2  s.  com*/
@Test
public void run() throws Exception {
    // We only need one repo server.
    TestRepositoryServer server = newRepositoryServer();

    // Generate some test content
    byte[] content = contentGenerator.newBinaryContent(1024);

    Dependency dep = contentGenerator.newDependency();
    Model pom = contentGenerator.newPom();
    pom.addDependency(dep);

    String path = contentGenerator.pathOf(dep);

    // Register the generated content by writing it to the path within the repo server's dir structure.
    // This way when the path is requested it can be downloaded instead of returning a 404.
    server.registerContent(path, content);
    server.registerContent(path + Main.SHA_SUFFIX, sha1Hex(content));
    server.registerContent(path + Main.MD5_SUFFIX, md5Hex(content));

    // All deps imply an accompanying POM file when using the POM artifact list reader, so we have to register one of these too.
    Model pomDep = contentGenerator.newPomFor(dep);
    String pomPath = contentGenerator.pathOf(pomDep);
    String md5Path = pomPath + Main.MD5_SUFFIX;
    String shaPath = pomPath + Main.SHA_SUFFIX;

    String pomStr = contentGenerator.pomToString(pomDep);

    server.registerContent(pomPath, pomStr);
    server.registerContent(md5Path, md5Hex(pomStr));
    server.registerContent(shaPath, sha1Hex(pomStr));

    // Write the plaintext file we'll use as input.
    File pomFile = temporaryFolder.newFile(getClass().getSimpleName() + ".pom");

    FileUtils.write(pomFile, contentGenerator.pomToString(pom));

    Options opts = new Options();
    opts.setBaseUrls(Collections.singletonList(server.getBaseUri()));

    // Capture the downloads here so we can verify the content.
    File downloads = temporaryFolder.newFolder();

    opts.setDownloads(downloads);
    opts.setLocations(Collections.singletonList(pomFile.getAbsolutePath()));

    // THIS IS THE KEY TO THIS TEST.
    opts.setSkipMetadata(true);

    // run `new Main(opts).run()` and return the Main instance so we can query it for errors, etc.
    Main finishedMain = run(opts);
    assertThat("Errors should be empty!", finishedMain.getErrors().isEmpty(), equalTo(true));

    // get the ProjectVersion info by pomPath reading from ArtifactPathInfo parse.
    ArtifactPathInfo artifactPathInfo = ArtifactPathInfo.parse(pomPath);
    ProjectVersionRef gav = artifactPathInfo.getProjectId();
    File metadataFile = Paths.get(opts.getDownloads().getAbsolutePath(),
            gav.getGroupId().replace('.', File.separatorChar), gav.getArtifactId(), "maven-metadata.xml")
            .toFile();
    assertThat("maven-metadata.xml for path: " + metadataFile.getParent()
            + " doesn't seem to have been generated!", metadataFile.exists(), equalTo(false));
}

From source file:com.appspresso.api.fs.DefaultFileSystem.java

/**
 * {@inheritDoc}/* w  ww .j a  v a 2 s.  com*/
 */
@Override
public String toVirtualPath(String path) {

    // String rootPath = null;
    // try {
    // // ? "/" ? ?    ?  .
    // rootPath = rootDirectory.getAbsolutePath().substring(1);
    // } catch(IndexOutOfBoundsException e) {
    // // IndexOutOfBoundsException ? ? File.
    // return null;
    // }
    //
    // // ? "/" .
    // if(path.charAt(0) == File.separatorChar) path = path.substring(1);
    // if(path.charAt(path.length() - 1) == File.separatorChar) path =
    // path.substring(path.length() - 1);
    //
    // if(path.startsWith(rootPath)) return
    // path.substring(rootPath.length());
    //
    // return null;

    // The path is a native full path.
    String nativeRootPath = rootDirectory.getAbsolutePath().substring(1);

    // ? "/" .
    try {
        if (nativeRootPath.charAt(0) == File.separatorChar)
            nativeRootPath = nativeRootPath.substring(1);
        if (nativeRootPath.charAt(nativeRootPath.length() - 1) == File.separatorChar)
            nativeRootPath = nativeRootPath.substring(0, nativeRootPath.length() - 1);
    } catch (IndexOutOfBoundsException e) {
        return null;
    }

    // ? "/" .
    try {
        if (path.charAt(0) == File.separatorChar)
            path = path.substring(1);
        if (path.charAt(path.length() - 1) == File.separatorChar)
            path = path.substring(0, path.length() - 1);
    } catch (IndexOutOfBoundsException e) {
        return null;
    }

    String rootPath = rootAxFile.getPath();
    if (path.startsWith(nativeRootPath))
        return rootPath + path.substring(nativeRootPath.length());
    return null;
}