List of usage examples for java.io File pathSeparatorChar
char pathSeparatorChar
To view the source code for java.io File pathSeparatorChar.
Click Source Link
From source file:org.zilverline.util.ClassFinder.java
/** * Convenience method that finds classes on the standard java classpath. * // www. j av a 2 s. com * @param superClass * @return list of discovered classes * @throws IOException * @throws ClassNotFoundException */ public static List findClassesThatExtend(Class superClass) throws IOException, ClassNotFoundException { log.debug("CLASSPATH: " + javaClassPath); String paths[] = javaClassPath.split("" + File.pathSeparatorChar); Class superClasses[] = new Class[1]; superClasses[0] = superClass; return ClassFinder.findClassesThatExtend(paths, superClasses); }
From source file:com.alibaba.rocketmq.filtersrv.filter.DynaCode.java
private static String extractClasspath(ClassLoader cl) { StringBuffer buf = new StringBuffer(); while (cl != null) { if (cl instanceof URLClassLoader) { URL urls[] = ((URLClassLoader) cl).getURLs(); for (int i = 0; i < urls.length; i++) { if (buf.length() > 0) { buf.append(File.pathSeparatorChar); }//from w ww . j av a 2 s .com String s = urls[i].getFile(); try { s = URLDecoder.decode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { continue; } File f = new File(s); buf.append(f.getAbsolutePath()); } } cl = cl.getParent(); } return buf.toString(); }
From source file:eu.optimis.elasticityengine.config.ConfigurationManager.java
/** * Load configuration file as specified in the system property, and fall * back on the default file if required. *///from www . java 2 s .co m private void loadConfigurationFile(String defaultConfigFilePath, String defaultConfigFileName) throws ConfigurationException { String configFilePath = System.getProperty("configuration.file.path"); String configFileName = System.getProperty("configuration.file.name"); String filePath = configFilePath == null ? defaultConfigFilePath : configFilePath; String fileName = configFileName == null ? defaultConfigFileName : configFileName; URL configURL; if (!filePath.endsWith(File.pathSeparator)) { filePath += File.pathSeparatorChar; } // Check if the file exists on the system, else try reading it from the // classpath File configFile = new File(filePath + fileName); if (configFile.exists()) { try { configURL = new URL(filePath + fileName); } catch (MalformedURLException e) { throw new ConfigurationException(e); } } else { configURL = this.getClass().getClassLoader().getResource(fileName); } PropertiesConfiguration config = null; try { config = new PropertiesConfiguration(configURL); } catch (ConfigurationException e) { if (configFileName.equals(defaultConfigFileName) && configFilePath.equals(defaultConfigFilePath)) { log.fatal("Could not find default configuration file: '" + defaultConfigFilePath + "'", e); throw e; } else { // Try default file too try { config = new PropertiesConfiguration(defaultConfigFilePath); } catch (ConfigurationException e2) { log.fatal("Could not find specified " + "configuration file: '" + configFilePath + File.pathSeparator + configFileName + "', and could not find default " + "configuration file: '" + defaultConfigFilePath + "'", e2); throw e2; } log.warn("Could not find specified " + "configuration file: '" + configFilePath + File.pathSeparator + configFileName + "', using default configuration at : '" + defaultConfigFilePath + File.pathSeparator + defaultConfigFileName + "'"); } } config.setThrowExceptionOnMissing(true); this.configuration = config; }
From source file:jetbrains.exodus.entitystore.TestBase.java
protected void storeArtifacts(String methodName) throws Exception { File backupDestDir = new File( getArtifactsPath() + getClass().getSimpleName() + File.pathSeparatorChar + methodName); if (!(backupDestDir.isDirectory()) && !(backupDestDir.mkdirs())) { throw new IOException("Failed to create " + backupDestDir.getAbsolutePath()); }/*w ww . j av a 2 s .c om*/ File[] files = getFilesToBackup(); for (File file : files) { if (!(file.exists())) { if (log.isWarnEnabled()) { log.warn("Can not find file while storing test artifacts: " + file.getAbsolutePath()); } continue; } CompressBackupUtil.tar(file, new File(backupDestDir, file.getName() + System.currentTimeMillis() + ".tar.bz")); } }
From source file:com.seer.datacruncher.eventtrigger.DynamicClassLoader.java
private static String extractClasspath(ClassLoader classLoader) { StringBuffer classLoaderBuf = new StringBuffer(); try {//from w w w .j a v a 2 s . c o m while (classLoader != null) { if (classLoader instanceof URLClassLoader) { URL urls[] = ((URLClassLoader) classLoader).getURLs(); for (int i = 0; i < urls.length; i++) { if (classLoaderBuf.length() > 0) { classLoaderBuf.append(File.pathSeparatorChar); } classLoaderBuf.append(URLDecoder.decode(urls[i].getFile(), "UTF-8").toString()); } } classLoader = classLoader.getParent(); } } catch (UnsupportedEncodingException e) { logger.error("Exception:" + e.getMessage(), e); } return classLoaderBuf.toString(); }
From source file:org.red5.server.jboss.JbossLoader.java
/** * Initialization//from w ww . j av a 2 s.c o m */ public void start() { logger.info("Loading jboss service"); System.setProperty("red5.deployment.type", "jboss"); logger.info("RED5 Server (http://www.osflash.org/red5)"); //logger.info("Loading red5 global context from: " + red5Config); long time = System.currentTimeMillis(); try { // get Red5 root as environment variable, this is set in the META-INF/jboss-service.xml String root = System.getProperty("red5.root"); logger.info("Red5 root: " + root); String configRoot = System.getProperty("red5.config_root"); logger.info("Red5 config root: " + configRoot); String classpath = System.getProperty("java.class.path"); System.setProperty("java.class.path", classpath + File.pathSeparatorChar + root + File.pathSeparatorChar + configRoot); logger.debug("Updated classpath: " + System.getProperty("java.class.path")); ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext( configRoot + "beanRefContext.xml"); /* GenericApplicationContext appCtx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( appCtx); Resource[] configResources = new Resource[] { new ClassPathResource("applicationContext.xml"), new ClassPathResource("red5-common.xml"), new ClassPathResource("red5-core.xml") }; xmlReader.loadBeanDefinitions(configResources); PropertiesBeanDefinitionReader propReader = new PropertiesBeanDefinitionReader( appCtx); propReader.loadBeanDefinitions(new ClassPathResource( "red5.properties")); ConfigurableBeanFactory factory = appCtx.getBeanFactory(); //register default add the context to the parent factory.registerSingleton("default.context", appCtx); appCtx.refresh(); */ this.setApplicationContext(appCtx); } catch (Exception e) { logger.error("Error during startup", e); } long startupIn = System.currentTimeMillis() - time; logger.info("Startup done in: " + startupIn + " ms"); }
From source file:pt.webdetails.cdc.plugin.HazelcastProcessLauncher.java
public void start() { String[] paths = getHazelcastClasspaths(); String classPathArg = StringUtils.join(paths, File.pathSeparatorChar); String java = joinPath(System.getProperty("java.home"), "bin", "java"); Config config = null;/*from w w w.ja v a2 s .c o m*/ XmlConfigBuilder configBuilder; try { configBuilder = new XmlConfigBuilder(getHazelcastStandaloneConfigFile()); config = configBuilder.build(); } catch (FileNotFoundException e1) { logger.error("launchProcess: " + getHazelcastStandaloneConfigFile() + " not found! Creating from current config."); config = HazelcastConfigHelper.cloneConfig(HazelcastManager.INSTANCE.getHazelcast().getConfig()); HazelcastConfigHelper.saveConfig(config, getHazelcastStandaloneConfigFile()); } try { //run with whole classpath ArrayList<String> cmds = getCommandLine(java, classPathArg, vmMemmory); String[] cmdsArray = cmds.toArray(new String[cmds.size()]); logger.debug("launching process: " + StringUtils.join(cmdsArray, " ")); procBuilder = new ProcessBuilder(cmds); procBuilder.directory( new File(PentahoSystem.getApplicationContext().getSolutionPath(joinPath("system", "cdc")))); process = procBuilder.start(); errorLogger = startDaemonThread(new ProcessOutputLogger(process.getErrorStream(), logger)); if (logger.isDebugEnabled()) { outputLogger = startDaemonThread(new ProcessOutputLogger(process.getInputStream(), logger)); } exitListener = startDaemonThread(new ProcessExitListener(process, logger)); // return process; } catch (Exception e) { logger.error(e); // return null; } }
From source file:org.openoffice.maven.Environment.java
/** * Guess office home from search path./* w ww . j a v a2s . c o m*/ * This method has default visibility for testing. * * @param path the path * @return the file */ static File guessOfficeHomeFromPATH(String path) { String[] pathElements = StringUtils.split(path, File.pathSeparatorChar); String baseDirName = getBaseDirName(); for (int i = 0; i < pathElements.length; i++) { String pathname = FilenameUtils.separatorsToUnix(pathElements[i]); pathname = FilenameUtils.normalizeNoEndSeparator(pathname); int n = pathname.lastIndexOf(baseDirName); if (n > 0) { return new File(pathname.substring(0, n)); } } return null; }
From source file:org.apache.ranger.plugin.util.PolicyRefresher.java
public PolicyRefresher(RangerBasePlugin plugIn, String serviceType, String appId, String serviceName, RangerAdminClient rangerAdmin, long pollingIntervalMs, String cacheDir) { if (LOG.isDebugEnabled()) { LOG.debug("==> PolicyRefresher(serviceName=" + serviceName + ").PolicyRefresher()"); }//ww w . j a v a 2 s .c om this.plugIn = plugIn; this.serviceType = serviceType; this.serviceName = serviceName; this.rangerAdmin = rangerAdmin; this.pollingIntervalMs = pollingIntervalMs; if (StringUtils.isEmpty(appId)) { appId = serviceType; } String cacheFilename = String.format("%s_%s.json", appId, serviceName); cacheFilename = cacheFilename.replace(File.separatorChar, '_'); cacheFilename = cacheFilename.replace(File.pathSeparatorChar, '_'); this.cacheFileName = cacheFilename; this.cacheDir = cacheDir; Gson gson = null; try { gson = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z").setPrettyPrinting().create(); } catch (Throwable excp) { LOG.fatal("PolicyRefresher(): failed to create GsonBuilder object", excp); } this.gson = gson; if (LOG.isDebugEnabled()) { LOG.debug("<== PolicyRefresher(serviceName=" + serviceName + ").PolicyRefresher()"); } }
From source file:org.apache.hadoop.hive.ant.DistinctElementsClassPath.java
/** * Returns a textual representation of the path after removing the duplicate files from the * original Path.//w w w.j a v a 2 s . c om */ @Override public String toString() { return org.apache.commons.lang.StringUtils.join(this.list(), File.pathSeparatorChar); }