Example usage for java.io File pathSeparator

List of usage examples for java.io File pathSeparator

Introduction

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

Prototype

String pathSeparator

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

Click Source Link

Document

The system-dependent path-separator character, represented as a string for convenience.

Usage

From source file:io.mangoo.maven.MangooMojo.java

private void startRunner(List<String> classpathItems, Set<String> includesSet, Set<String> excludesSet,
        Set<Path> watchDirectories) {
    try {/*from   www . j  a  va 2 s .c  o  m*/
        Runner machine = new Runner(Application.class.getName(),
                StringUtils.join(classpathItems, File.pathSeparator), project.getBasedir());

        Trigger restartTrigger = new Trigger(machine);
        restartTrigger.setSettleDownMillis(settleDownMillis);
        restartTrigger.start();

        Watcher watcher = new Watcher(watchDirectories, includesSet, excludesSet, restartTrigger);

        machine.restart();
        watcher.run(); //NOSONAR
    } catch (IOException e) {
        getLog().error(e);
    }
}

From source file:com.autentia.common.util.FileSystemUtils.java

/**
 * Devuelve el path completo donde se encuentra el fichero <tt>fileName</tt>. Este fichero <tt>fileName</tt> se
 * busca en el la lista de directorios definida por <tt>searchPath</tt>. Esta es un lista de directorios del estilo
 * del PATH o del LD_LIBRARY_PATH, es decir una lista de directorios donde el separador es ';' en Windows o ':' en
 * Unix./*from w  w w .  j a v  a  2s  . c  o  m*/
 * 
 * @see File#pathSeparatorChar
 * @param searchPath lista de directorios del estilo del PATH o del LD_LIBRARY_PATH, es decir una lista de
 *            directorios donde el separador es ';' en Windows o ':' en Unix
 * @param fileName nombre del fichero que se quiere buscar en <tt>searchPath</tt>.
 * @return el path completo donde se encuentra el fichero <tt>fileName</tt>.
 * @throws MissingResourceException si no se encuentra <tt>fileName</tt> en ningn direcotorio definido por
 *             <tt>searchPath</tt>.
 */
public static String searchFileInPath(String searchPath, String fileName) {
    final String[] paths = searchPath.split(File.pathSeparator);
    for (int i = 0; i < paths.length; i++) {
        String filePath = paths[i];
        if (!filePath.endsWith(File.separator)) {
            filePath += File.separator;
        }
        filePath += fileName;
        if (log.isDebugEnabled())
            log.trace("Searching: " + filePath);

        final File propertiesFile = new File(filePath);
        if (propertiesFile.canRead()) {
            if (log.isDebugEnabled())
                log.trace("Found and is readable: " + filePath);
            return filePath;
        }
    }
    throw new MissingResourceException(
            "Cannot find file '" + fileName + "' in path '" + searchPath + "', or cannot be read",
            FileSystemUtils.class.getName(), fileName);
}

From source file:org.ebayopensource.turmeric.eclipse.typelibrary.codegen.model.TypeLibModelTransformer.java

private static String getXJCClassPath() throws CoreException, IOException {
    StringBuffer xjcClassPath = new StringBuffer("");
    for (IProject typeLibProject : WorkspaceUtil
            .getProjectsByNature(TypeLibraryProjectNature.getTypeLibraryNatureId())) {
        xjcClassPath.append(typeLibProject.getLocation().toFile().getCanonicalPath());
        xjcClassPath.append(File.pathSeparatorChar);
    }/*from   w  w  w.  j a  v a2  s  .  c om*/
    return StringUtils.substringBeforeLast(xjcClassPath.toString(), File.pathSeparator);

}

From source file:org.codehaus.mojo.webtest.components.AntExecutor.java

/**
 * Build a class path based on a list of artifacts. Please
 * not that this is copy & wasted from maven-antrun-plugin.
 *
 * @param artifacts  the artifacts constituting the class path
 * @param antProject the ant project/*from ww w  . j  av a  2 s  . com*/
 * @return a path
 * @throws DependencyResolutionRequiredException
 *          not dependencies were resolved
 */
public Path getPathFromArtifacts(Collection artifacts, Project antProject)
        throws DependencyResolutionRequiredException {
    if (artifacts == null) {
        return new Path(antProject);
    }

    List list = new ArrayList(artifacts.size());
    for (Iterator i = artifacts.iterator(); i.hasNext();) {
        Artifact a = (Artifact) i.next();
        File file = a.getFile();
        if (file == null) {
            throw new DependencyResolutionRequiredException(a);
        }
        list.add(file.getPath());
    }

    Path p = new Path(antProject);
    p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));

    return p;
}

From source file:com.opensymphony.xwork2.util.finder.UrlSet.java

public UrlSet excludePaths(String pathString) throws MalformedURLException {
    String[] paths = pathString.split(File.pathSeparator);
    UrlSet urlSet = this;
    for (String path : paths) {
        if (StringUtils.isNotEmpty(path)) {
            File file = new File(path);
            urlSet = urlSet.exclude(file);
        }/*from  ww w  .  j a  v  a  2s  .  c o m*/
    }
    return urlSet;
}

From source file:org.cyberlis.pyloader.PythonPluginLoader.java

private Properties setDefaultPythonPath(Properties props, String file_path) {
    String pythonPathProp = props.getProperty("python.path");
    String new_value;
    if (pythonPathProp == null) {
        new_value = file_path;
    } else {//from ww w .ja  v  a2  s.  c  om
        new_value = pythonPathProp + java.io.File.pathSeparator + file_path + java.io.File.pathSeparator;
    }
    props.setProperty("python.path", new_value);
    return props;
}

From source file:org.jboss.as.test.integration.web.annotationsmodule.WebModuleDeploymentTestCase.java

private static File getModulePath() {
    String modulePath = System.getProperty("module.path", null);
    if (modulePath == null) {
        String jbossHome = System.getProperty("jboss.home", null);
        if (jbossHome == null) {
            throw new IllegalStateException("Neither -Dmodule.path nor -Djboss.home were set");
        }// www . j a  va 2s  .c  o m
        modulePath = jbossHome + File.separatorChar + "modules";
    } else {
        modulePath = modulePath.split(File.pathSeparator)[0];
    }
    File moduleDir = new File(modulePath);
    if (!moduleDir.exists()) {
        throw new IllegalStateException("Determined module path does not exist");
    }
    if (!moduleDir.isDirectory()) {
        throw new IllegalStateException("Determined module path is not a dir");
    }
    return moduleDir;
}

From source file:averroes.JarFile.java

/**
 * Add the generated AverroesLibraryClass file to the Jar file.
 * /*w ww  .  jav  a  2s .  c o m*/
 * @throws IOException
 * @throws URISyntaxException
 */
public void addAverroesLibraryClassFile() throws IOException, URISyntaxException {
    File dir = Paths.libraryClassesOutputDirectory();
    File placeholderJar = Paths.placeholderLibraryJarFile();
    File averroesLibraryClassJar = Paths.averroesLibraryClassJarFile();

    File file = FileUtils.listFiles(dir, new String[] { "class" }, true).stream()
            .filter(f -> relativize(dir, f).equals(Names.AVERROES_LIBRARY_CLASS_BC_SIG + ".class"))
            .collect(Collectors.toList()).get(0);
    String className = relativize(dir, file);

    // Add the class file to the separately crafted JAR file.
    if (file.isFile()) {
        add(dir, file);
    } else {
        throw new IllegalStateException("cannot find " + Names.AVERROES_LIBRARY_CLASS
                + System.getProperty("line.separator") + "Invalid path given: " + fileName);
    }
    close();

    // Set BCEL's repository class path.
    SyntheticRepository rep = SyntheticRepository.getInstance(new ClassPath(averroesLibraryClassJar
            + File.pathSeparator + placeholderJar + File.pathSeparator + Paths.organizedApplicationJarFile()));
    Repository.setRepository(rep);

    // Now add the class files (including ones from placeholder JAR) to the
    // BCEL repository.
    ClassParser parser = new ClassParser(averroesLibraryClassJar.getPath(), className);
    JavaClass cls = parser.parse();
    bcelClasses.add(cls);

    // Now we need to add all the BCEL classes (including ones from previous
    // placeholder JAR to force BCEL to load
    // those crafted files when it looks them up
    bcelClasses.forEach(c -> Repository.getRepository().storeClass(c));

    // Now verify all the generated class files
    verify();
}

From source file:org.bimserver.ifcengine.JvmIfcEngine.java

public void startJvm() throws RenderEngineException {
    try {/*  w ww .j ava  2s .c  om*/
        if (!tempDir.exists()) {
            tempDir.mkdir();
        }
        StringBuilder command = new StringBuilder("java");
        if (nativeBaseDir.toString().contains(" ")) {
            command.append(" -Djna.library.path=\"" + nativeBaseDir.toString() + "\"");
        } else {
            command.append(" -Djna.library.path=" + nativeBaseDir.toString());
        }
        if (tempDir.getAbsolutePath().toString().contains(" ")) {
            command.append(" -Djava.io.tmpdir=\"" + tempDir.getAbsolutePath().toString() + "\"");
        } else {
            command.append(" -Djava.io.tmpdir=" + tempDir.getAbsolutePath().toString());
        }
        command.append(" -classpath ");
        command.append("\"");
        if (classPath != null) {
            File file = new File(classPath);
            if (file.isDirectory()) {
                for (File subFile : file.listFiles()) {
                    if (subFile.getName().endsWith(".jar")) {
                        command.append(subFile.getAbsolutePath() + File.pathSeparator);
                    }
                }
            }
            command.append(classPath + File.pathSeparator);
        }
        command.append("\"");
        String mem = "512m";
        if (Runtime.getRuntime().maxMemory() == Long.MAX_VALUE) {
        } else {
            int megs = (int) (Runtime.getRuntime().maxMemory() / 2000000);
            if (megs > 1024) {
                megs = 1024;
            }
            mem = String.valueOf(megs + "m");
        }
        command.append(" -Xmx" + mem);
        command.append(" -Xms" + mem);

        command.append(" org.bimserver.ifcengine.jvm.IfcEngineServer");
        if (schemaFile.getAbsolutePath().contains(" ")) {
            command.append(" \"" + schemaFile.getAbsolutePath() + "\"");
        } else {
            command.append(" " + schemaFile.getAbsolutePath());
        }
        //         LOGGER.info(command.toString());
        process = Runtime.getRuntime().exec(command.toString());
        in = new DataInputStream(new BufferedInputStream(process.getInputStream()));
        out = new DataOutputStream(new BufferedOutputStream(process.getOutputStream()));
        err = process.getErrorStream();
        startErrorHandler();
        Thread thread = new Thread("JvmIfcEngine") {
            @Override
            public void run() {
                int result;
                try {
                    result = process.waitFor();
                    if (result != 0) {
                        lastException = new RenderEngineException("Process ended with errorcode: " + result);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start();
    } catch (Exception e) {
        throw new RenderEngineException(e);
    }
}

From source file:com.apporiented.hermesftp.utils.IOUtils.java

/**
 * Tries to figure out the application's home directory.
 * //from   ww w.j ava  2s .co m
 * @return The directory.
 */
public static File getHomeDir() {
    File result = null;
    String cp = System.getProperty("java.class.path");
    StringTokenizer tokenizer = new StringTokenizer(cp, File.pathSeparator);
    if (tokenizer.countTokens() == 1) {
        File jar = new File(tokenizer.nextToken());
        try {
            result = jar.getCanonicalFile().getParentFile().getParentFile();
        } catch (IOException e) {
        }
    } else {
        File userDir = new File(System.getProperty("user.dir"));
        result = userDir.getAbsoluteFile().getParentFile();
    }
    return result;
}