List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:org.n52.wps.webadmin.ConfigUploadBean.java
public void compile(String fileName) { ClassLoader cl = this.getClass().getClassLoader(); List<URL> classpath = new ArrayList<URL>(); if (cl instanceof URLClassLoader) { URLClassLoader cl2 = (URLClassLoader) cl; for (URL jar : cl2.getURLs()) { classpath.add(jar);//from w ww. ja v a2 s. com } } String classPath = System.getProperty("java.class.path"); for (String path : classPath.split(File.pathSeparator)) { try { classpath.add(new URL("file:" + path)); } catch (MalformedURLException e) { System.err.println("Wrong url: " + e.getMessage()); e.printStackTrace(); } } StringBuffer sb = new StringBuffer(); for (URL jar : classpath) { if (SystemUtils.IS_OS_WINDOWS == false) { sb.append(jar.getPath()); sb.append(File.pathSeparatorChar); } else { sb.append(jar.getPath().substring(1)); sb.append(File.pathSeparatorChar); } } String ops[] = new String[] { "-classpath", sb.toString() }; List<String> opsIter = new ArrayList<String>(); try { for (String s : ops) { // XXX test usage, removed use of deprecated method // ((ArrayList) opsIter).add(URLDecoder.decode(s)); ((ArrayList) opsIter).add(URLDecoder.decode(s, Charset.forName("UTF-8").toString())); } } catch (UnsupportedEncodingException e) { LOGGER.warn(e.getMessage(), e); } File[] files1 = new File[1]; files1[0] = new File(fileName); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> compilationUnits1 = fileManager .getJavaFileObjectsFromFiles(Arrays.asList(files1)); compiler.getTask(null, fileManager, null, opsIter, null, compilationUnits1).call(); try { fileManager.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.netbeans.modules.mongodb.native_tools.MongoNativeTool.java
public String getExecFileName() { final StringBuilder sb = new StringBuilder(); sb.append(execBaseName);/*from w w w. jav a 2s. co m*/ if (SystemUtils.IS_OS_WINDOWS) { sb.append(".exe"); } return sb.toString(); }
From source file:org.ngrinder.recorder.browser.BrowserFactoryEx.java
/** * Get the supported browser./*from ww w.j ava 2s . c o m*/ * * @return supported browser list */ public static List<BrowserType> getSupportedBrowser() { List<BrowserType> result = newArrayList(); if (SystemUtils.IS_OS_WINDOWS) { addIfAvailable(result, BrowserType.IE); if (BrowserType.Mozilla15.isSupported()) { addIfAvailable(result, BrowserType.Mozilla15); } else if (BrowserType.Mozilla.isSupported()) { addIfAvailable(result, BrowserType.Mozilla); } } else if (SystemUtils.IS_OS_MAC) { if (BrowserType.Mozilla15.isSupported()) { addIfAvailable(result, BrowserType.Mozilla15); } else if (BrowserType.Mozilla.isSupported()) { addIfAvailable(result, BrowserType.Mozilla); } else { addIfAvailable(result, BrowserType.Safari); } } else { if (BrowserType.Mozilla.isSupported()) { addIfAvailable(result, BrowserType.Mozilla); } else { addIfAvailable(result, BrowserType.Mozilla15); } } return result; }
From source file:org.ngrinder.recorder.browser.BrowserFactoryEx.java
/** * Set up the given browser with the given end points. * /* www . j av a 2 s .c o m*/ * @param browser * browser to be set up * @param endPoints * endPoints to which the browser connects to */ public static void setupBrowserProxy(Browser browser, ProxyEndPointPair endPoints) { if (endPoints == null) { return; } ProxyConfig proxyConfig = browser.getServices().getProxyConfig(); ProxyServer proxyServer = new ProxyServer(endPoints.getHttpEndPoint().getHost(), endPoints.getHttpEndPoint().getPort()); proxyConfig.setProxy(ServerType.HTTP, proxyServer); // Only IE supports HTTPS Recording due to JXBrowser XULRunner problem. // This should be fixed soon. if (SystemUtils.IS_OS_WINDOWS) { ProxyServer sslProxyServer = new ProxyServer(endPoints.getHttpsEndPoint().getHost(), endPoints.getHttpsEndPoint().getPort()); proxyConfig.setProxy(ServerType.SSL, sslProxyServer); } }
From source file:org.ngrinder.recorder.Recorder.java
protected boolean isInAppBrowserRecodingSupportEnv() { return SystemUtils.IS_OS_WINDOWS; }
From source file:org.nomt.base.shell.ShellUtil.java
/** * @description ping a destination(domain name or IP), if reachable, return * true, else return/* w w w . jav a 2s .c o m*/ * false * @param destination * @return * @author Rain Tang */ public boolean ping(String destination) { String command; boolean result = false; if (SystemUtils.IS_OS_WINDOWS) { command = "ping -n 3 " + destination; } else { command = "ping -c 3 " + destination; } String output = this.executeCommand(command); if (output.contains("from")) { result = true; logger.debug("ping {} successfully.", destination); } return result; }
From source file:org.nuxeo.common.utils.TestFileUtils.java
@Test public void testFilePathMethods() { String path, testPath;/*from ww w .j av a 2 s . co m*/ if (SystemUtils.IS_OS_WINDOWS) { path = "\\a\\b\\c\\d.pdf"; testPath = "\\a\\b\\c"; } else { path = "/a/b/c/d.pdf"; testPath = "/a/b/c"; } assertEquals(testPath, FileUtils.getParentPath(path)); assertEquals("pdf", FileUtils.getFileExtension(path)); assertEquals("d.pdf", FileUtils.getFileName(path)); assertEquals("d", FileUtils.getFileNameNoExt(path)); path = "a.gif"; assertNull(FileUtils.getParentPath(path)); assertEquals("gif", FileUtils.getFileExtension(path)); assertEquals("a.gif", FileUtils.getFileName(path)); assertEquals("a", FileUtils.getFileNameNoExt(path)); path = "a"; assertNull(FileUtils.getParentPath(path)); assertNull(FileUtils.getFileExtension(path)); assertEquals("a", FileUtils.getFileName(path)); assertEquals("a", FileUtils.getFileNameNoExt(path)); }
From source file:org.nuxeo.common.utils.TestFileUtils.java
/** * @deprecated Since 7.4. Use {@link SystemUtils#IS_OS_WINDOWS} *///from www .j a v a 2 s .c o m @Deprecated public static boolean isWindows() { return SystemUtils.IS_OS_WINDOWS; }
From source file:org.nuxeo.ecm.diff.content.TestContentDiffAdapter.java
protected void checkContentDiff(String expectedBlobPath, Blob contentDiffBlob) { try {// ww w.j ava 2 s. c o m Blob expectedblob = Blobs.createBlob(FileUtils.getResourceFileFromContext(expectedBlobPath)); String expected = expectedblob.getString(); String actual = contentDiffBlob.getString(); if (SystemUtils.IS_OS_WINDOWS) { // make tests pass under Windows expected = expected.trim(); expected = expected.replace("\n", ""); expected = expected.replace("\r", ""); actual = actual.trim(); actual = actual.replace("\n", ""); actual = actual.replace("\r", ""); } assertEquals(expected, actual); } catch (IOException ioe) { fail("Error while getting content diff blob strings"); } }
From source file:org.nuxeo.ecm.platform.filemanager.TestFileManagerService.java
@Test public void testCreateNote() throws Exception { File file = getTestFile("test-data/hello.html"); Blob input = Blobs.createBlob(file, "text/html"); DocumentModel doc = service.createDocumentFromBlob(coreSession, input, workspace.getPathAsString(), true, "test-data/hello.html"); assertNotNull(doc);//from www.j av a 2s .com assertEquals("hello.html", doc.getProperty("dublincore", "title")); String expectedNoteTest = NOTE_HTML_CONTENT; String noteText = ((String) doc.getProperty("note", "note")); if (SystemUtils.IS_OS_WINDOWS) { expectedNoteTest = expectedNoteTest.trim(); expectedNoteTest = expectedNoteTest.replace("\n", ""); expectedNoteTest = expectedNoteTest.replace("\r", ""); noteText = expectedNoteTest.trim(); noteText = expectedNoteTest.replace("\n", ""); noteText = expectedNoteTest.replace("\r", ""); } assertEquals(expectedNoteTest, noteText); }