Java Code Examples for java.io.File.pathSeparatorChar()

The following are Jave code examples for showing how to use pathSeparatorChar() of the java.io.File class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: CacheWriter.java   View Source Code Vote up 6 votes
public void setDir (String dir, boolean clean) throws IOException {
    StringBuffer sb = new StringBuffer(dir);
    if (sb.charAt(sb.length()-1) != File.pathSeparatorChar) {
        sb.append (File.separatorChar);
    }
    this.dir = sb.toString();
    File f = new File (dir);
    if (!f.exists()) {
        f.mkdir();
    }
    if (clean) {
        File mf = new File (this.dir + filename + ".metadata");
        File fc = new File (this.dir + filename + ".cache");
        if (mf.exists()) {
            mf.delete();
        }
        if (fc.exists()) {
            fc.delete();
        }
    }
}
 
Example 2
Project: r8   File: ProguardConfigurationParser.java   View Source Code Vote up 6 votes
private Path parseFileName() throws ProguardRuleParserException {
  skipWhitespace();
  int start = position;
  int end = position;
  while (!eof(end)) {
    char current = contents.charAt(end);
    if (current != File.pathSeparatorChar && !Character.isWhitespace(current)) {
      end++;
    } else {
      break;
    }
  }
  if (start == end) {
    throw parseError("File name expected");
  }
  position = end;
  return baseDirectory.resolve(contents.substring(start, end));
}
 
Example 3
Project: Reer   File: FileNormaliser.java   View Source Code Vote up 5 votes
boolean isNormalisingRequiredForAbsolutePath(String filePath) {
    if (File.pathSeparatorChar != '/') {
        filePath = filePath.replace(File.pathSeparatorChar, '/');
    }
    if (filePath.charAt(0) != '/') {
        throw new IllegalArgumentException("Only absolute unix paths are currently handled. filePath=" + filePath);
    }
    if (filePath.contains("/../") || filePath.contains("/./") || filePath.contains("//")) {
        return true;
    }
    if (filePath.endsWith("/") || filePath.endsWith("/.") || filePath.endsWith("/..")) {
        return true;
    }
    return false;
}
 
Example 4
Project: openjdk-jdk10   File: CheckGraalInvariants.java   View Source Code Vote up 5 votes
protected String getClassPath() {
    String bootclasspath;
    if (Java8OrEarlier) {
        bootclasspath = System.getProperty("sun.boot.class.path");
    } else {
        bootclasspath = System.getProperty("jdk.module.path") + File.pathSeparatorChar + System.getProperty("jdk.module.upgrade.path");
    }
    return bootclasspath;
}
 
Example 5
Project: incubator-netbeans   File: NewClustersRebootCallback.java   View Source Code Vote up 5 votes
private static void createFileWithNewClustersForNbexec(File newCluster, String nbdirs, File udir) throws FileNotFoundException, IOException {
    newCluster.mkdirs();
    nbdirs = nbdirs + File.pathSeparatorChar + newCluster.getAbsolutePath();
    File fileWithClustersForShell = new File(udir, "update"+File.separatorChar+"download"+File.separatorChar+"netbeans.dirs");
    fileWithClustersForShell.getParentFile().mkdirs();
    fileWithClustersForShell.createNewFile();
    OutputStream os = new FileOutputStream(fileWithClustersForShell);
    os.write(nbdirs.getBytes());
    os.close();
}
 
Example 6
Project: openjdk-jdk10   File: RuntimeTest.java   View Source Code Vote up 5 votes
@Test(dataProvider = "jarFiles")
void testMVJarAsLib(String jar, int mainVer, int helperVer, int resVer)
        throws Throwable {
    String[] apps = { "UseByImport", "UseByReflection" };
    for (String app : apps) {
        String[] command = {"-cp",
                jar + File.pathSeparatorChar + "classes/test/", app };
        System.out.println("Command arguments:" + Arrays.asList(command));
        System.out.println();
        java(command).shouldHaveExitValue(SUCCESS)
                .shouldContain("Main version: " + mainVer)
                .shouldContain("Helpers version: " + helperVer)
                .shouldContain("Resource version: " + resVer);
    }
}
 
Example 7
Project: beaker-notebook-archive   File: ScalaEvaluator.java   View Source Code Vote up 5 votes
protected ClassLoader newClassLoader() throws MalformedURLException
{
  logger.debug("creating new loader");

  loader_cp = "";
  for (int i = 0; i < classPath.size(); i++) {
    loader_cp += classPath.get(i);
    loader_cp += File.pathSeparatorChar;
  }
  loader_cp += outDir;
  DynamicClassLoaderSimple cl = new DynamicClassLoaderSimple(ClassLoader.getSystemClassLoader());
  cl.addJars(classPath);
  cl.addDynamicDir(outDir);
  return cl;
}
 
Example 8
Project: beaker-notebook-archive   File: ScalaEvaluator.java   View Source Code Vote up 5 votes
protected ClassLoader newAutoCompleteClassLoader() throws MalformedURLException
{
  logger.debug("creating new autocomplete loader");
  acloader_cp = "";
  for (int i = 0; i < classPath.size(); i++) {
    acloader_cp += classPath.get(i);
    acloader_cp += File.pathSeparatorChar;
  }
  acloader_cp += outDir;
      
  DynamicClassLoaderSimple cl = new DynamicClassLoaderSimple(ClassLoader.getSystemClassLoader());
  cl.addJars(classPath);
  cl.addDynamicDir(outDir);
  return cl;
}
 
Example 9
Project: javaide   File: WordReader.java   View Source Code Vote up 5 votes
private boolean isDelimiter(char character)
{
    return character == '@' ||
           character == '{' ||
           character == '}' ||
           character == '(' ||
           character == ')' ||
           character == ',' ||
           character == ';' ||
           character == File.pathSeparatorChar;
}
 
Example 10
Project: OpenJSharp   File: XmlSchemaGenerator.java   View Source Code Vote up 5 votes
private static String calculateRelativePath(String uri, String base, boolean fileUrl) {
    // if this is a file URL (very likely), and if this is on a case-insensitive file system,
    // then treat it accordingly.
    boolean onWindows = File.pathSeparatorChar==';';

    if (base == null) {
        return null;
    }
    if ((fileUrl && onWindows && startsWithIgnoreCase(uri,base)) || uri.startsWith(base)) {
        return uri.substring(base.length());
    } else {
        return "../" + calculateRelativePath(uri, getParentUriPath(base), fileUrl);
    }
}
 
Example 11
Project: incubator-netbeans   File: ProjectModelTest.java   View Source Code Vote up 4 votes
public void testUpdateCompilationUnits() throws Exception {
    List sources;
    List units = new ArrayList();
    List expectedUnits;
    
    ProjectModel pm = createEmptyProjectModel();
    
    sources = generateSources(new String[]{"src1", "src2"});
    JavaProjectGenerator.JavaCompilationUnit cu = new JavaProjectGenerator.JavaCompilationUnit();
    cu.packageRoots = Collections.singletonList("src1");
    JavaProjectGenerator.JavaCompilationUnit.CP cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.classpath = "cp1"+File.pathSeparatorChar+"cp2";
    cp.mode = "compile";
    cu.classpath = Collections.singletonList(cp);
    cu.output = Arrays.asList(new String[]{"out1", "out2"});
    units.add(cu);
    cu = new JavaProjectGenerator.JavaCompilationUnit();
    cu.packageRoots = Collections.singletonList("src2");
    cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.classpath = "cp2"+File.pathSeparatorChar+"cp3";
    cp.mode = "compile";
    cu.classpath = Collections.singletonList(cp);
    cu.output = Arrays.asList(new String[]{"out3"});
    units.add(cu);
    pm.setSourceFolders(sources);
    pm.setJavaCompilationUnits(units);
    pm.setSourceLevel("S_L_14");
    pm.updateCompilationUnits(false);
    assertEquals("Compilation units has to be merged into one", 1, units.size());
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(0);
    assertEquals("Compilation unit has to have two package roots", 2, cu.packageRoots.size());
    assertTrue("Missing expected package root: src1", cu.packageRoots.contains("src1"));
    assertTrue("Missing expected package root: src2", cu.packageRoots.contains("src2"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_14"));
    
    pm.setSourceFolders(sources);
    pm.setJavaCompilationUnits(units);
    pm.setSourceLevel("S_L_15");
    pm.updateCompilationUnits(true);
    assertEquals("Compilation units has to be cloned into two", 2, units.size());
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(0);
    assertEquals("Compilation unit has to have one package root", 1, cu.packageRoots.size());
    assertTrue("Missing expected package root", cu.packageRoots.contains("src1"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_15"));
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(1);
    assertEquals("Compilation unit has to have one package root", 1, cu.packageRoots.size());
    assertTrue("Missing expected package root", cu.packageRoots.contains("src2"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_15"));
    
}
 
Example 12
Project: incubator-netbeans   File: BaseUtilities.java   View Source Code Vote up 4 votes
/** Get the operating system on which NetBeans is running.
* @return one of the <code>OS_*</code> constants (such as {@link #OS_WINNT})
*/
public static int getOperatingSystem() {
    if (operatingSystem == -1) {
        String osName = System.getProperty("os.name");

        if ("Windows NT".equals(osName)) { // NOI18N
            operatingSystem = OS_WINNT;
        } else if ("Windows 95".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN95;
        } else if ("Windows 98".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN98;
        } else if ("Windows 2000".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN2000;
        } else if ("Windows Vista".equals(osName)) { // NOI18N
            operatingSystem = OS_WINVISTA;
        } else if (osName.startsWith("Windows ")) { // NOI18N
            operatingSystem = OS_WIN_OTHER;
        } else if ("Solaris".equals(osName)) { // NOI18N
            operatingSystem = OS_SOLARIS;
        } else if (osName.startsWith("SunOS")) { // NOI18N
            operatingSystem = OS_SOLARIS;
        }
        // JDK 1.4 b2 defines os.name for me as "Redhat Linux" -jglick
        else if (osName.endsWith("Linux")) { // NOI18N
            operatingSystem = OS_LINUX;
        } else if ("HP-UX".equals(osName)) { // NOI18N
            operatingSystem = OS_HP;
        } else if ("AIX".equals(osName)) { // NOI18N
            operatingSystem = OS_AIX;
        } else if ("Irix".equals(osName)) { // NOI18N
            operatingSystem = OS_IRIX;
        } else if ("SunOS".equals(osName)) { // NOI18N
            operatingSystem = OS_SUNOS;
        } else if ("Digital UNIX".equals(osName)) { // NOI18N
            operatingSystem = OS_TRU64;
        } else if ("OS/2".equals(osName)) { // NOI18N
            operatingSystem = OS_OS2;
        } else if ("OpenVMS".equals(osName)) { // NOI18N
            operatingSystem = OS_VMS;
        } else if (osName.equals("Mac OS X")) { // NOI18N
            operatingSystem = OS_MAC;
        } else if (osName.startsWith("Darwin")) { // NOI18N
            operatingSystem = OS_MAC;
        } else if (osName.toLowerCase(Locale.US).startsWith("freebsd")) { // NOI18N 
            operatingSystem = OS_FREEBSD;
        } else if ("OpenBSD".equals(osName)) { // NOI18N
            operatingSystem = OS_OPENBSD;
        } else if (File.pathSeparatorChar == ':') { // NOI18N
            operatingSystem = OS_UNIX_OTHER;
        } else {
            operatingSystem = OS_OTHER;
        }
    }

    return operatingSystem;
}
 
Example 13
Project: marathonv5   File: OSUtils.java   View Source Code Vote up 4 votes
public static boolean isWindowsOS() {
    return File.pathSeparatorChar == ';';
}
 
Example 14
Project: OpenDA   File: BmiModelFactory.java   View Source Code Vote up 4 votes
/**
 * Creates and starts a server process that is capable of running the python
 * model with the given properties.
 */
private static Process startModelProcess(String host, int port, String pythonExecutable, File opendaPythonPath,
		File modelPythonPath, String modelPythonModuleName, String modelPythonClassName, File runDir)
		throws IOException {
	ProcessBuilder builder = new ProcessBuilder();
	builder.directory(runDir);
	//TODO Niels: use Result.putMessage(), otherwise log messages just disappear. AK
	LOGGER.info("Running process with current working directory " + runDir.getAbsolutePath());
	Results.putMessage("Running process with current working directory " + runDir.getAbsolutePath());

	// add openda python code and model python code to python path.
	char pathSeparatorChar = File.pathSeparatorChar;
	String currentPythonPath = builder.environment().get("PYTHONPATH");
	String newPythonPath = opendaPythonPath.getAbsolutePath() + pathSeparatorChar
			+ modelPythonPath.getAbsolutePath() + pathSeparatorChar + currentPythonPath;
	builder.environment().put("PYTHONPATH", newPythonPath);
	LOGGER.info("Running with PYTHONPATH: " + newPythonPath);
	LOGGER.info("Running with PATH: " + builder.environment().get("PATH"));
	
	// this assumes we can login with ssh without a password, or specifying
	// any options
	if (host != null && host != "127.0.0.1" ) {
		builder.command().add("ssh");
		builder.command().add(host);
		builder.command().add("cd");
		builder.command().add(runDir + ";");
		builder.command().add("PYTHONPATH=" + newPythonPath + pathSeparatorChar + "$PYTHONPATH");
	}

	File pythonMainScript = new File(opendaPythonPath, "thrift_bmi_raster_server.py");
	builder.command().add(pythonExecutable);
	builder.command().add("-u");
	
	builder.command().add(pythonMainScript.getAbsolutePath());
	builder.command().add(modelPythonModuleName);
	builder.command().add(modelPythonClassName);
	builder.command().add(host);
	builder.command().add(Integer.toString(port));

	builder.redirectError(Redirect.INHERIT);
	builder.redirectOutput(Redirect.INHERIT);

	LOGGER.info("Running command: " + Arrays.toString(builder.command().toArray()));
	return builder.start();
}
 
Example 15
Project: beaker-notebook-archive   File: ScalaEvaluator.java   View Source Code Vote up 4 votes
protected void newEvaluator() throws MalformedURLException
{
  logger.debug("creating new evaluator");
  shell = new ScalaEvaluatorGlue(newClassLoader(),
    loader_cp + File.pathSeparatorChar + System.getProperty("java.class.path"), outDir);

  if (!imports.isEmpty()) {
    for (int i = 0; i < imports.size(); i++) {
      String imp = imports.get(i).trim();
      if (imp.startsWith("import"))
        imp = imp.substring(6).trim();
      if (imp.endsWith(".*"))
        imp = imp.substring(0,imp.length()-1) + "_";
      if(!imp.isEmpty()) {
        logger.debug("importing : {}", imp);
        if(!shell.addImport(imp))
          logger.warn("ERROR: cannot add import '{}'", imp);
      }
    }
  }

  logger.debug("creating beaker object");

  // ensure object is created
  NamespaceClient.getBeaker(sessionId);

  String r = shell.evaluate2(
      "import com.twosigma.beaker.NamespaceClient\n"+
      "import language.dynamics\n"+
      "var _beaker = NamespaceClient.getBeaker(\""+sessionId+"\")\n"+
      "object beaker extends Dynamic {\n"+
      "  def selectDynamic( field : String ) = _beaker.get(field)\n"+
      "  def updateDynamic (field : String)(value : Any) : Any = {\n"+
      "    _beaker.set(field,value)\n"+
      "    return value\n"+
      "  }\n"+
      "  def applyDynamic(methodName: String)(args: AnyRef*) = {\n"+
      "    def argtypes = args.map(_.getClass)\n"+
      "    def method = _beaker.getClass.getMethod(methodName, argtypes: _*)\n"+
      "    method.invoke(_beaker,args: _*)\n"+
      "  }\n"+
      "}\n" 
      );
  if(r!=null && !r.isEmpty()) {
    logger.warn("ERROR creating beaker object: {}", r);
  }
}
 
Example 16
Project: beaker-notebook-archive   File: ScalaEvaluator.java   View Source Code Vote up 4 votes
protected void newAutoCompleteEvaluator() throws MalformedURLException
{
  logger.debug("creating new autocomplete evaluator");
  acshell = new ScalaEvaluatorGlue(newAutoCompleteClassLoader(),
    acloader_cp + File.pathSeparatorChar + System.getProperty("java.class.path"), outDir);

  if (!imports.isEmpty()) {
    for (int i = 0; i < imports.size(); i++) {
      String imp = imports.get(i).trim();
      if (imp.startsWith("import"))
        imp = imp.substring(6).trim();
      if (imp.endsWith(".*"))
        imp = imp.substring(0,imp.length()-1) + "_";
      if(!imp.isEmpty()) {
        if(!acshell.addImport(imp))
          logger.warn("ERROR: cannot add import '{}'", imp);
      }
    }
  }
  
  // ensure object is created
  NamespaceClient.getBeaker(sessionId);

  String r = acshell.evaluate2(
      "import com.twosigma.beaker.NamespaceClient\n"+
      "import language.dynamics\n"+
      "var _beaker = NamespaceClient.getBeaker(\""+sessionId+"\")\n"+
      "object beaker extends Dynamic {\n"+
      "  def selectDynamic( field : String ) = _beaker.get(field)\n"+
      "  def updateDynamic (field : String)(value : Any) : Any = {\n"+
      "    _beaker.set(field,value)\n"+
      "    return value\n"+
      "  }\n"+
      "  def applyDynamic(methodName: String)(args: AnyRef*) = {\n"+
      "    def argtypes = args.map(_.getClass)\n"+
      "    def method = _beaker.getClass.getMethod(methodName, argtypes: _*)\n"+
      "    method.invoke(_beaker,args: _*)\n"+
      "  }\n"+
      "}\n" 
      );
  if(r!=null && !r.isEmpty()) {
    logger.warn("ERROR creating beaker beaker: {}", r);
  }

}
 
Example 17
Project: beaker-notebook-archive   File: GroovyEvaluator.java   View Source Code Vote up 4 votes
protected GroovyClassLoader newEvaluator() throws MalformedURLException {

    try {
      Class.forName("org.codehaus.groovy.control.customizers.ImportCustomizer");
    } catch (ClassNotFoundException e1) {
      String gjp = System.getenv(GROOVY_JAR_PATH);
      String errorMsg = null;
      if (gjp != null && !gjp.isEmpty()) {
        errorMsg = "Groovy libary not found, GROOVY_JAR_PATH = " + gjp;
      } else {
        errorMsg = "Default groovy libary not found. No GROOVY_JAR_PATH variable set.";
      }
      throw new GroovyNotFoundException(errorMsg);
    }

    ImportCustomizer icz = new ImportCustomizer();

    if (!imports.isEmpty()) {
      for (String importLine : imports) {
        if (importLine.startsWith(STATIC_WORD_WITH_SPACE)) {

          String pureImport = importLine
                  .replace(STATIC_WORD_WITH_SPACE, StringUtils.EMPTY)
                  .replace(DOT_STAR_POSTFIX, StringUtils.EMPTY);

          if (importLine.endsWith(DOT_STAR_POSTFIX)) {
            icz.addStaticStars(pureImport);
          } else {
            int index = pureImport.lastIndexOf('.');
            if (index == -1) {
              continue;
            }
            icz.addStaticImport(pureImport.substring(0, index), pureImport.substring(index + 1));
          }

        } else {

          if (importLine.endsWith(DOT_STAR_POSTFIX)) {
            icz.addStarImports(importLine.replace(DOT_STAR_POSTFIX, StringUtils.EMPTY));
          } else {
            icz.addImports(importLine);
          }

        }
      }
    }
    CompilerConfiguration config = new CompilerConfiguration().addCompilationCustomizers(icz);

    String acloader_cp = "";
    for (int i = 0; i < classPath.size(); i++) {
      acloader_cp += classPath.get(i);
      acloader_cp += File.pathSeparatorChar;
    }
    acloader_cp += outDir;

    config.setClasspath(acloader_cp);

    compilerConfiguration = config;

    scriptBinding = new Binding();
    return new GroovyClassLoader(newClassLoader(), compilerConfiguration);
  }
 
Example 18
Project: javaide   File: FileNameParser.java   View Source Code Vote up 4 votes
public StringMatcher parse(String regularExpression)
{
    int           index;
    StringMatcher nextMatcher = new EmptyStringMatcher();

    // Look for wildcards.
    for (index = 0; index < regularExpression.length(); index++)
    {
        // Is there a '**' wildcard?
        if (regularExpression.regionMatches(index, "**", 0, 2))
        {
            // Create a matcher for the wildcard and, recursively, for the
            // remainder of the string.
            nextMatcher =
                new VariableStringMatcher(null,
                                          null,
                                          0,
                                          Integer.MAX_VALUE,
                                          parse(regularExpression.substring(index + 2)));
            break;
        }

        // Is there a '*' wildcard?
        else if (regularExpression.charAt(index) == '*')
        {
            // Create a matcher for the wildcard and, recursively, for the
            // remainder of the string.
            nextMatcher =
                new VariableStringMatcher(null,
                                          new char[] { File.pathSeparatorChar, '/' },
                                          0,
                                          Integer.MAX_VALUE,
                                          parse(regularExpression.substring(index + 1)));
            break;
        }

        // Is there a '?' wildcard?
        else if (regularExpression.charAt(index) == '?')
        {
            // Create a matcher for the wildcard and, recursively, for the
            // remainder of the string.
            nextMatcher =
                new VariableStringMatcher(null,
                                          new char[] { File.pathSeparatorChar, '/' },
                                          1,
                                          1,
                                          parse(regularExpression.substring(index + 1)));
            break;
        }
    }

    // Return a matcher for the fixed first part of the regular expression,
    // if any, and the remainder.
    return index != 0 ?
        (StringMatcher)new FixedStringMatcher(regularExpression.substring(0, index), nextMatcher) :
        (StringMatcher)nextMatcher;
}
 
Example 19
Project: openjdk-jdk10   File: ClassLoader.java   View Source Code Vote up 4 votes
private static String[] initializePath(String propName) {
    String ldPath = System.getProperty(propName, "");
    int ldLen = ldPath.length();
    char ps = File.pathSeparatorChar;
    int psCount = 0;

    if (ClassLoaderHelper.allowsQuotedPathElements &&
            ldPath.indexOf('\"') >= 0) {
        // First, remove quotes put around quoted parts of paths.
        // Second, use a quotation mark as a new path separator.
        // This will preserve any quoted old path separators.
        char[] buf = new char[ldLen];
        int bufLen = 0;
        for (int i = 0; i < ldLen; ++i) {
            char ch = ldPath.charAt(i);
            if (ch == '\"') {
                while (++i < ldLen &&
                        (ch = ldPath.charAt(i)) != '\"') {
                    buf[bufLen++] = ch;
                }
            } else {
                if (ch == ps) {
                    psCount++;
                    ch = '\"';
                }
                buf[bufLen++] = ch;
            }
        }
        ldPath = new String(buf, 0, bufLen);
        ldLen = bufLen;
        ps = '\"';
    } else {
        for (int i = ldPath.indexOf(ps); i >= 0;
                i = ldPath.indexOf(ps, i + 1)) {
            psCount++;
        }
    }

    String[] paths = new String[psCount + 1];
    int pathStart = 0;
    for (int j = 0; j < psCount; ++j) {
        int pathEnd = ldPath.indexOf(ps, pathStart);
        paths[j] = (pathStart < pathEnd) ?
                ldPath.substring(pathStart, pathEnd) : ".";
        pathStart = pathEnd + 1;
    }
    paths[psCount] = (pathStart < ldLen) ?
            ldPath.substring(pathStart, ldLen) : ".";
    return paths;
}
 
Example 20
Project: shabdiz   File: LocalPlatform.java   View Source Code Vote up 2 votes
private LocalPlatform() {

        super(System.getProperty(OS_NAME_PROPERTY_NAME), File.pathSeparatorChar, File.separatorChar, System.getProperty(TMP_DIR_PROPERTY_NAME));
    }