java.io.File#pathSeparatorChar ( )源码实例Demo

下面列出了java.io.File#pathSeparatorChar ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: CacheWriter.java
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();
        }
    }
}
 
源代码2 项目: baratine   文件: DynamicClassLoader.java
/**
 * Returns the resource path with most specific first.
 */
public final String getResourcePathSpecificFirst()
{
  ArrayList<String> pathList = new ArrayList<String>();

  buildResourcePathSpecificFirst(pathList);

  StringBuilder sb = new StringBuilder();
  char sep = File.pathSeparatorChar;

  if (pathList.size() == 0)
    return "";

  sb.append(pathList.get(0));
  for (int i = 1; i < pathList.size(); i++) {
    sb.append(sep);
    sb.append(pathList.get(i));
  }

  return sb.toString();
}
 
源代码3 项目: spring-ldap   文件: CompilerInterface.java
public static void compile(String directory, String file) throws Exception {

        ProcessBuilder pb = new ProcessBuilder(
                new String[] { "javac", 
                               "-cp", "."+File.pathSeparatorChar+"target"+File.separatorChar+"classes"+
                                  File.pathSeparatorChar+System.getProperty("java.class.path"),
                                  directory+File.separatorChar+file });

        pb.redirectErrorStream(true);
        Process proc = pb.start();
        InputStream is = proc.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);

        char[] buf = new char[1024];
        int count;
        StringBuilder builder = new StringBuilder();
        while ((count = isr.read(buf)) > 0) {
            builder.append(buf, 0, count);
        }
        
        boolean ok = proc.waitFor() == 0;

        if (!ok) {
            throw new RuntimeException(builder.toString());
        }
    }
 
源代码4 项目: baratine   文件: BaratineBoot.java
private static String toNative(String filePath)
{
  if (File.pathSeparatorChar == '/') {
    return filePath;
  }
  
  if (filePath.indexOf(':') == 2 && filePath.startsWith("/")) {
    filePath = filePath.substring(1);
  }
  
  return filePath;
}
 
源代码5 项目: wildfly-core   文件: SuspendOnSoftKillTestCase.java
private void startContainer(int suspendTimeout) throws Exception {

        suspendTimeout = suspendTimeout < 1 ? suspendTimeout : TimeoutUtil.adjust(suspendTimeout);

        jbossArgs = System.getProperty("jboss.args");
        String newArgs = jbossArgs == null ? "" : jbossArgs;
        newArgs += " -D[Standalone] -Dorg.wildfly.sigterm.suspend.timeout=" + suspendTimeout;
        System.setProperty("jboss.args", newArgs);

        if (File.pathSeparatorChar == ':'){
            processUtil = new UnixProcessUtil();
        } else {
            processUtil = new WindowsProcessUtil();
        }

        // Start the server
        serverController.start();

        // If there's already the deployment there from a previous test, remove it
        try {
            serverController.undeploy(WEB_SUSPEND_JAR);
        } catch (Exception ignored) {
            // assume it wasn't deployed. if it was we'll fail below
        }

        JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
        war.addPackage(SuspendResumeHandler.class.getPackage());
        war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
        war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
        war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                new RuntimePermission("createXnioWorker"),
                new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                new SocketPermission("*", "accept,resolve")
        ), "permissions.xml");
        serverController.deploy(war, WEB_SUSPEND_JAR);
    }
 
源代码6 项目: jdk8u60   文件: XmlSchemaGenerator.java
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);
    }
}
 
源代码7 项目: java-n-IDE-for-Android   文件: WordReader.java
private boolean isDelimiter(char character)
{
    return character == '@' ||
           character == '{' ||
           character == '}' ||
           character == '(' ||
           character == ')' ||
           character == ',' ||
           character == ';' ||
           character == File.pathSeparatorChar;
}
 
源代码8 项目: nopol   文件: JPFRunner.java
private String createClassPath(URL[] classpath) {
	classpath = addJPFLibraryToCassPath(classpath);
	String stringClassPath = outputCompiledFile.getAbsolutePath() + File.pathSeparatorChar;
	for (int i = 0; i < classpath.length; i++) {
		URL url = classpath[i];
		stringClassPath += url.getPath() + File.pathSeparatorChar;
	}
	return stringClassPath;
}
 
源代码9 项目: openjdk-jdk9   文件: RuntimeTest.java
@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);
    }
}
 
源代码10 项目: uima-uimaj   文件: InstallationController.java
/**
 * Builds <code>CLASSPATH</code> for the installed component, including <code>CLASSPATH</code>
 * for all separate delegate components that are utilized by the main installed component, if any.
 * 
 * @return The <code>CLASSPATH</code> for the installed component, or <code>null</code>, if
 *         the component has not been installed.
 * @throws IOException
 *           If any I/O exception occurred.
 */
public String buildComponentClassPath() throws IOException {
  if (_insdObject != null) {
    StringBuffer cpBuffer = new StringBuffer();
    // build main component classpath
    String mainClassPath = buildComponentClassPath(_mainComponentRootPath, _insdObject, true);
    cpBuffer.append(mainClassPath);
    // add component classpath for possible delegate components
    if (_installationTable.size() > 0) {
      Enumeration<String> dlgIdList = _installationTable.keys();
      while (dlgIdList.hasMoreElements()) {
        // process next delegate component
        String dlgId = dlgIdList.nextElement();
        String dlgRootPath = _installationTable.get(dlgId);
        InstallationDescriptor dlgInsD = _installationInsDs.get(dlgId);
        String dlgClassPath = buildComponentClassPath(dlgRootPath, dlgInsD, true);
        if (dlgClassPath.length() > 0) {
          if (cpBuffer.length() > 0
                  && cpBuffer.charAt(cpBuffer.length() - 1) != File.pathSeparatorChar)
            cpBuffer.append(File.pathSeparatorChar);
          cpBuffer.append(dlgClassPath);
        }
      }
    }
    return cpBuffer.toString();
  }
  return null;
}
 
源代码11 项目: aspectj-maven-plugin   文件: AjcHelper.java
/**
 * Constructs AspectJ compiler classpath string
 *
 * @param project the Maven Project
 * @param pluginArtifacts the plugin Artifacts
 * @param outDirs the outputDirectories
 * @return a os spesific classpath string
 */
@SuppressWarnings( "unchecked" )
public static String createClassPath( MavenProject project, List<Artifact> pluginArtifacts, List<String> outDirs )
{
    String cp = new String();
    Set<Artifact> classPathElements = Collections.synchronizedSet( new LinkedHashSet<Artifact>() );
    Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
    classPathElements.addAll( dependencyArtifacts == null ? Collections.<Artifact>emptySet() : dependencyArtifacts );
    classPathElements.addAll( project.getArtifacts() );
    classPathElements.addAll( pluginArtifacts == null ? Collections.<Artifact>emptySet() : pluginArtifacts );
    for ( Artifact classPathElement  : classPathElements )
    {
        File artifact = classPathElement.getFile();
        if ( null != artifact )
        {
          String type = classPathElement.getType();
          if (!type.equals("pom")){
            cp += classPathElement.getFile().getAbsolutePath();
            cp += File.pathSeparatorChar;                
          }
        }
    }
    Iterator<String> outIter = outDirs.iterator();
    while ( outIter.hasNext() )
    {
        cp += outIter.next();
        cp += File.pathSeparatorChar;
    }

    if ( cp.endsWith( "" + File.pathSeparatorChar ) )
    {
        cp = cp.substring( 0, cp.length() - 1 );
    }

    cp = StringUtils.replace( cp, "//", "/" );
    return cp;
}
 
源代码12 项目: nopol   文件: JavaLibraryTest.java
@Test
public void joinClasspaths() throws MalformedURLException {
	URL url = new URL("file:///imaginary/project/folder/src");
	URL url2 = new URL("file:///imaginary/dependency/lib.jar");
	String classpath = asClasspath(new URL[] {url, url2});
	Character classPathSeparator = File.pathSeparatorChar;
	assertEquals("/imaginary/project/folder/src" + classPathSeparator + "/imaginary/dependency/lib.jar", classpath);
}
 
源代码13 项目: nopol   文件: Main.java
/**
 * Launch nopol on project
 * @param cpClassFolder : location of project's compiled java
 * @param cpTestFolder : location of project's compiled tests
 * @param srcClassFolder : location of project's java
 * @param srcTestFolder : location of project's tests
 * @param destSrcTestFolder : location for the kept tests
 * @param destCpTestFolder : location to compile the kept tests
 * @param dependencies : all dependencies for the project and evosuite tests
 * @param testClasses : test class used to generate patch (null for all tests)
 * @return  the list of patch found by nopol
 */
public static List<Patch> NopolPatchGeneration(String cpClassFolder,String  cpTestFolder, 
        String srcClassFolder, String srcTestFolder, String destSrcTestFolder, 
        String destCpTestFolder, String dependencies, String[] testClasses) {

    //sources contain main java and test java.
    String sources = srcClassFolder+File.pathSeparatorChar+srcTestFolder+File.pathSeparatorChar+destSrcTestFolder;
    String cp = cpClassFolder+File.pathSeparatorChar+cpTestFolder+File.pathSeparatorChar+destCpTestFolder+File.pathSeparatorChar+dependencies;

    //create sources array
    String[] sourcesArray = sources.split(File.pathSeparator);
    File[] sourceFiles = new File[sourcesArray.length];
    for(int i = 0; i<sourcesArray.length; i++){
        sourceFiles[i] = FileLibrary.openFrom(sourcesArray[i]);	
    }


    //create getClasspath
    //URL[] classPath = FileUtils.getURLs(sources.split(File.pathSeparator));
    URL[] classPath = JavaLibrary.classpathFrom(cp);

    logger.debug("Launch nopol with:");
    logger.debug("sources = "+sources);
    logger.debug("classpath = "+cp);
    logger.debug("testClasses = "+testClasses);

    NopolContext nopolContext = new NopolContext(sourceFiles, classPath, testClasses);
    nopolContext.setMaxTimeInMinutes(maxTime);
    nopolContext.setType(nopolType);

    NoPol nopol = new NoPol(nopolContext);
    NopolResult status = nopol.build();

    return status.getPatches();
}
 
源代码14 项目: baratine   文件: CauchoUtil.java
/**
 * Returns the system classpath, including the bootpath
 */
public static String getClassPath()
{
  if (_classPath != null)
    return _classPath;

  String cp = System.getProperty("java.class.path");

  String boot = System.getProperty("sun.boot.class.path");
  if (boot != null && ! boot.equals(""))
    cp = cp + File.pathSeparatorChar + boot;

  Pattern pattern = Pattern.compile("" + File.pathSeparatorChar);

  String []path = pattern.split(cp);

  CharBuffer cb = new CharBuffer();

  for (int i = 0; i < path.length; i++) {
    PathImpl subpath = VfsOld.lookup(path[i]);

    if (subpath.canRead() || subpath.isDirectory()) {
      if (cb.length() > 0)
        cb.append(File.pathSeparatorChar);

      cb.append(path[i]);
    }
  }

  _classPath = cb.toString();

  return _classPath;
}
 
源代码15 项目: openjdk-8-source   文件: Main.java
/**
 * Remove smart javac wrapper arguments, before feeding
 * the args to the plain javac.
 */
static String[] removeWrapperArgs(String[] args) {
    String[] out = new String[args.length];
    // The first source path index is remembered
    // here. So that all following can be concatenated to it.
    int source_path = -1;
    // The same for class path.
    int class_path = -1;
    // And module path.
    int module_path = -1;
    int j = 0;
    for (int i = 0; i<args.length; ++i) {
        if (args[i].equals("-src") ||
            args[i].equals("-x") ||
            args[i].equals("-i") ||
            args[i].equals("-xf") ||
            args[i].equals("-if") ||
            args[i].equals("-copy") ||
            args[i].equals("-tr") ||
            args[i].equals("-j")) {
            // Just skip it and skip following value
            i++;
        } else if (args[i].startsWith("--server:")) {
            // Just skip it.
        } else if (args[i].startsWith("--log=")) {
            // Just skip it.
        } else if (args[i].equals("--permit-unidentified-artifacts")) {
            // Just skip it.
        } else if (args[i].equals("--permit-sources-without-package")) {
            // Just skip it.
        } else if (args[i].equals("--compare-found-sources")) {
            // Just skip it and skip verify file name
            i++;
        } else if (args[i].equals("-sourcepath")) {
            if (source_path == -1) {
                source_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[source_path+1] = out[source_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
        } else if (args[i].equals("-classpath") || args[i].equals("-cp")) {
            if (class_path == -1) {
                class_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[class_path+1] = out[class_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
        } else if (args[i].equals("-modulepath")) {
            if (module_path == -1) {
                module_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[module_path+1] = out[module_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
         } else {
            // Copy argument.
            out[j] = args[i];
            j++;
        }
    }
    String[] ret = new String[j];
    System.arraycopy(out, 0, ret, 0, j);
    return ret;
}
 
源代码16 项目: scheduling   文件: TestScheduler.java
public static String testClasspath() {
    return (getRmHome() + File.separator + "dist" + File.separator + "lib" + File.separator + "*") +
           File.pathSeparatorChar + getRmHome() + File.separator + "addons" + File.separator + "*" +
           filterClassPath(System.getProperty("java.class.path"));
}
 
源代码17 项目: wildfly-core   文件: RespawnHttpTestCase.java
@BeforeClass
public static void createProcessController() throws IOException, URISyntaxException, NoSuchAlgorithmException {

    // Setup client
    utils = TestControllerUtils.create("remote+http", DomainTestSupport.masterAddress, HC_PORT, getCallbackHandler());
    client = new TestControllerClient(utils.getConfiguration(), utils.getExecutor());

    final String testName = RespawnHttpTestCase.class.getSimpleName();
    final File domains = new File("target" + File.separator + "domains" + File.separator + testName);
    final File masterDir = new File(domains, "master");
    final String masterDirPath = masterDir.getAbsolutePath();
    domainConfigDir = new File(masterDir, "configuration");
    // TODO this should not be necessary
    domainConfigDir.mkdirs();

    if (File.pathSeparatorChar == ':'){
        processUtil = new UnixProcessUtil();
    } else {
        processUtil = new WindowsProcessUtil();
    }

    String jbossHome = System.getProperty("jboss.home");
    if (jbossHome == null) {
        throw new IllegalStateException("-Djboss.home must be set");
    }

    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    URL url = tccl.getResource("domain-configs/domain-respawn-http.xml");
    Assert.assertNotNull(url);
    File domainXml = new File(url.toURI());
    url = tccl.getResource("host-configs/respawn-master-http.xml");
    hostXml = new File(url.toURI());

    Assert.assertTrue(domainXml.exists());
    Assert.assertTrue(hostXml.exists());
    copyFile(domainXml, domainConfigDir);
    copyFile(hostXml, domainConfigDir);

    // No point backing up the file in a test scenario, just write what we need.
    File usersFile = new File(domainConfigDir, "mgmt-users.properties");
    Files.write(usersFile.toPath(),
            ("slave=" + new UsernamePasswordHashUtil().generateHashedHexURP("slave", "ManagementRealm", "slave_user_password".toCharArray())+"\n").getBytes(StandardCharsets.UTF_8));

    String localRepo = System.getProperty("settings.localRepository");

    final String address = System.getProperty("jboss.test.host.master.address", "127.0.0.1");

    List<String> args = new ArrayList<String>();
    args.add("-jboss-home");
    args.add(jbossHome);
    args.add("-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--");
    if(localRepo != null) {
        args.add("-Dmaven.repo.local=" + localRepo);
    }
    args.add("-Dorg.jboss.boot.log.file=" + masterDirPath + "/log/host-controller.log");
    args.add("-Dlogging.configuration=file:" + jbossHome + "/domain/configuration/logging.properties");
    args.add("-Djboss.test.host.master.address=" + address);
    TestSuiteEnvironment.getIpv6Args(args);
    args.add("-Xms64m");
    args.add("-Xmx512m");
    args.add("-XX:MaxMetaspaceSize=256m");
    String cliJvmArgs = System.getProperty("cli.jvm.args");
    if (cliJvmArgs != null && !cliJvmArgs.trim().isEmpty()) {
        args.addAll(Arrays.asList(cliJvmArgs.split("\\s+")));
    }
    args.add("--");
    args.add("-default-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--host-config=" + hostXml.getName());
    args.add("--domain-config=" + domainXml.getName());
    args.add("-Djboss.test.host.master.address=" + address);
    args.add("-Djboss.domain.base.dir=" + masterDir.getAbsolutePath());
    if(localRepo != null) {
        args.add("-Dmaven.repo.local=" + localRepo);
    }
    args.add("--interprocess-hc-address");
    args.add(address);
    args.add("--pc-address");
    args.add(address);

    log.info(args.toString());

    processController = Main.start(args.toArray(new String[args.size()]));
}
 
源代码18 项目: netbeans   文件: ProjectModelTest.java
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"));
    
}
 
源代码19 项目: netbeans   文件: BaseUtilities.java
/** 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;
}
 
源代码20 项目: git-client-plugin   文件: CliGitAPITempFileTest.java
/**
 * inline ${@link hudson.Functions#isWindows()} to prevent a transient
 * remote classloader issue
 */
private static boolean isWindows() {
    return File.pathSeparatorChar == ';';
}