List of usage examples for java.io File pathSeparator
String pathSeparator
To view the source code for java.io File pathSeparator.
Click Source Link
From source file:org.apache.sysml.yarn.DMLYarnClient.java
private Map<String, String> constructEnvionmentMap(YarnConfiguration yconf) throws IOException { Map<String, String> eMap = new HashMap<String, String>(); //setup default app master environment StringBuilder classpath = new StringBuilder(); for (String value : yconf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { if (classpath.length() > 0) classpath.append(File.pathSeparator); classpath.append(value.trim());/* w w w .j a v a 2s . c o m*/ } //setup mapreduce appmaster environment (for robustness if not included in default environment) //for example, by default HDP 2.2 did not include mapred client libraries in this configuration //note: we cannot use MRConfigurationNames.MR_APPLICATION_CLASSPATH because it refers to HDFS and $PWD that needs to be setup Map<String, String> env = System.getenv(); String mapred_home = null; //get mapred home via alternative environment variables if (env.containsKey(MAPRED_HOME_ENV_CONST)) { mapred_home = env.get(MAPRED_HOME_ENV_CONST); } else if (env.containsKey(HADOOP_HOME_ENV_CONST)) { String tmp = env.get(HADOOP_HOME_ENV_CONST); mapred_home = tmp + File.separator + ".." + File.separator + "hadoop-mapreduce"; } //concatenate mapred home libs to classpath if (mapred_home != null) { if (classpath.length() > 0) classpath.append(File.pathSeparator); classpath.append(mapred_home + File.separator + "*"); classpath.append(File.pathSeparator); classpath.append(mapred_home + File.separator + "lib" + File.separator + "*"); } eMap.put(Environment.CLASSPATH.name(), classpath.toString()); MRApps.setClasspath(eMap, yconf); LOG.debug("Constructed environment classpath: " + classpath.toString()); return eMap; }
From source file:org.apache.storm.daemon.supervisor.SyncSupervisorEvent.java
private String resourcesJar() throws IOException { String path = Utils.currentClasspath(); if (path == null) { return null; }/*from w w w. j av a 2 s. c om*/ String[] paths = path.split(File.pathSeparator); List<String> jarPaths = new ArrayList<String>(); for (String s : paths) { if (s.endsWith(".jar")) { jarPaths.add(s); } } List<String> rtn = new ArrayList<String>(); int size = jarPaths.size(); for (int i = 0; i < size; i++) { if (Utils.zipDoesContainDir(jarPaths.get(i), ConfigUtils.RESOURCES_SUBDIR)) { rtn.add(jarPaths.get(i)); } } if (rtn.size() == 0) return null; return rtn.get(0); }
From source file:org.apache.jmeter.JMeter.java
/** * Takes the command line arguments and uses them to determine how to * startup JMeter./*from w ww. j ava 2s. com*/ * * Called reflectively by {@link NewDriver#main(String[])} * @param args The arguments for JMeter */ public void start(String[] args) { CLArgsParser parser = new CLArgsParser(args, options); String error = parser.getErrorString(); if (error == null) {// Check option combinations boolean gui = parser.getArgumentById(NONGUI_OPT) == null; boolean nonGuiOnly = parser.getArgumentById(REMOTE_OPT) != null || parser.getArgumentById(REMOTE_OPT_PARAM) != null || parser.getArgumentById(REMOTE_STOP) != null; if (gui && nonGuiOnly) { error = "-r and -R and -X are only valid in non-GUI mode"; } } if (null != error) { System.err.println("Error: " + error); System.out.println("Usage"); System.out.println(CLUtil.describeOptions(options).toString()); // repeat the error so no need to scroll back past the usage to see it System.out.println("Error: " + error); return; } try { initializeProperties(parser); // Also initialises JMeter logging /* * The following is needed for HTTPClient. * (originally tried doing this in HTTPSampler2, * but it appears that it was done too late when running in GUI mode) * Set the commons logging default to Avalon Logkit, if not already defined */ if (System.getProperty("org.apache.commons.logging.Log") == null) { // $NON-NLS-1$ System.setProperty("org.apache.commons.logging.Log" // $NON-NLS-1$ , "org.apache.commons.logging.impl.LogKitLogger"); // $NON-NLS-1$ } Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { if (!(e instanceof ThreadDeath)) { log.error("Uncaught exception: ", e); System.err.println("Uncaught Exception " + e + ". See log file for details."); } } }); log.info(JMeterUtils.getJMeterCopyright()); log.info("Version " + JMeterUtils.getJMeterVersion()); logProperty("java.version"); //$NON-NLS-1$ logProperty("java.vm.name"); //$NON-NLS-1$ logProperty("os.name"); //$NON-NLS-1$ logProperty("os.arch"); //$NON-NLS-1$ logProperty("os.version"); //$NON-NLS-1$ logProperty("file.encoding"); // $NON-NLS-1$ log.info("Max memory =" + Runtime.getRuntime().maxMemory()); log.info("Available Processors =" + Runtime.getRuntime().availableProcessors()); log.info("Default Locale=" + Locale.getDefault().getDisplayName()); log.info("JMeter Locale=" + JMeterUtils.getLocale().getDisplayName()); log.info("JMeterHome=" + JMeterUtils.getJMeterHome()); logProperty("user.dir", " ="); //$NON-NLS-1$ log.info("PWD =" + new File(".").getCanonicalPath());//$NON-NLS-1$ log.info("IP: " + JMeterUtils.getLocalHostIP() + " Name: " + JMeterUtils.getLocalHostName() + " FullName: " + JMeterUtils.getLocalHostFullName()); setProxy(parser); updateClassLoader(); if (log.isDebugEnabled()) { String jcp = System.getProperty("java.class.path");// $NON-NLS-1$ String[] bits = jcp.split(File.pathSeparator); log.debug("ClassPath"); for (String bit : bits) { log.debug(bit); } } // Set some (hopefully!) useful properties long now = System.currentTimeMillis(); JMeterUtils.setProperty("START.MS", Long.toString(now));// $NON-NLS-1$ Date today = new Date(now); // so it agrees with above // TODO perhaps should share code with __time() function for this... JMeterUtils.setProperty("START.YMD", new SimpleDateFormat("yyyyMMdd").format(today));// $NON-NLS-1$ $NON-NLS-2$ JMeterUtils.setProperty("START.HMS", new SimpleDateFormat("HHmmss").format(today));// $NON-NLS-1$ $NON-NLS-2$ if (parser.getArgumentById(VERSION_OPT) != null) { displayAsciiArt(); } else if (parser.getArgumentById(HELP_OPT) != null) { displayAsciiArt(); System.out.println(JMeterUtils.getResourceFileAsText("org/apache/jmeter/help.txt"));// $NON-NLS-1$ } else if (parser.getArgumentById(OPTIONS_OPT) != null) { displayAsciiArt(); System.out.println(CLUtil.describeOptions(options).toString()); } else if (parser.getArgumentById(SERVER_OPT) != null) { // Start the server try { RemoteJMeterEngineImpl.startServer(JMeterUtils.getPropDefault("server_port", 0)); // $NON-NLS-1$ } catch (Exception ex) { System.err.println("Server failed to start: " + ex); log.error("Giving up, as server failed with:", ex); throw ex; } startOptionalServers(); } else { String testFile = null; CLOption testFileOpt = parser.getArgumentById(TESTFILE_OPT); if (testFileOpt != null) { testFile = testFileOpt.getArgument(); if (USE_LAST_JMX.equals(testFile)) { testFile = LoadRecentProject.getRecentFile(0);// most recent } } CLOption testReportOpt = parser.getArgumentById(REPORT_GENERATING_OPT); if (testReportOpt != null) { // generate report from existing file String reportFile = testReportOpt.getArgument(); extractAndSetReportOutputFolder(parser); ReportGenerator generator = new ReportGenerator(reportFile, null); generator.generate(); } else if (parser.getArgumentById(NONGUI_OPT) == null) { // not non-GUI => GUI startGui(testFile); startOptionalServers(); } else { // NON-GUI must be true extractAndSetReportOutputFolder(parser); CLOption rem = parser.getArgumentById(REMOTE_OPT_PARAM); if (rem == null) { rem = parser.getArgumentById(REMOTE_OPT); } CLOption jtl = parser.getArgumentById(LOGFILE_OPT); String jtlFile = null; if (jtl != null) { jtlFile = processLAST(jtl.getArgument(), ".jtl"); // $NON-NLS-1$ } CLOption reportAtEndOpt = parser.getArgumentById(REPORT_AT_END_OPT); if (reportAtEndOpt != null) { if (jtlFile == null) { throw new IllegalUserActionException("Option -" + ((char) REPORT_AT_END_OPT) + " requires -" + ((char) LOGFILE_OPT) + " option"); } } startNonGui(testFile, jtlFile, rem, reportAtEndOpt != null); startOptionalServers(); } } } catch (IllegalUserActionException e) { System.out.println("Incorrect Usage:" + e.getMessage()); System.out.println(CLUtil.describeOptions(options).toString()); } catch (Throwable e) { log.fatalError("An error occurred: ", e); System.out.println("An error occurred: " + e.getMessage()); System.exit(1); // TODO - could this be return? } }
From source file:org.apache.hadoop.hdfs.server.namenode.AvatarNodeNew.java
/** * Return the configuration that should be used by this instance of AvatarNode * Copy fsimages from the remote shared device. *//* w w w .j a va 2 s .c o m*/ static Configuration copyFsImage(Configuration conf, StartupOption opt) throws IOException { String img0 = conf.get("dfs.name.dir.shared0"); String img1 = conf.get("dfs.name.dir.shared1"); String edit0 = conf.get("dfs.name.edits.dir.shared0"); String edit1 = conf.get("dfs.name.edits.dir.shared1"); Collection<String> namedirs = conf.getStringCollection("dfs.name.dir"); Collection<String> editsdir = conf.getStringCollection("dfs.name.edits.dir"); String msg = ""; if (img0 == null || img0.isEmpty()) { msg += "No values specified in dfs.name.dir.share0"; } if (img1 == null || img1.isEmpty()) { msg += " No values specified in dfs.name.dir.share1"; } if (edit0 == null || edit0.isEmpty()) { msg += " No values specified in dfs.name.edits.dir.share0"; } if (edit1 == null || edit1.isEmpty()) { msg += " No values specified in dfs.name.edits.dir.share1"; } if (msg.length() != 0) { LOG.info(msg); throw new IOException(msg); } // verify that the shared dirctories are not specified as dfs.name.dir for (String str : namedirs) { if (str.equalsIgnoreCase(img0)) { msg = "The name specified in dfs.name.dir.shared0 " + img0 + " is already part of dfs.name.dir "; } if (str.equalsIgnoreCase(img1)) { msg += " The name specified in dfs.name.dir.shared1 " + img1 + " is already part of dfs.name.dir "; } } if (msg.length() != 0) { LOG.info(msg); throw new IOException(msg); } // verify that the shared edits directories are not specified as dfs.name.edits.dir for (String str : editsdir) { if (str.equalsIgnoreCase(edit0)) { msg = "The name specified in dfs.name.edits.dir.shared0 " + img0 + " is already part of dfs.name.dir "; } if (str.equalsIgnoreCase(edit1)) { msg += " The name specified in dfs.name.edits.dir.shared1 " + img1 + " is already part of dfs.name.dir "; } } if (msg.length() != 0) { LOG.info(msg); throw new IOException(msg); } // // record the fstime of the checkpoint that we are about to sync from // setStartCheckpointTime(conf); // if we are starting as the standby then // record the fstime of the checkpoint that we are about to sync from if (opt == StartupOption.STANDBY) { setStartCheckpointTime(conf); } File primary = new File(img0); File standby = new File(img1); String mdate = dateForm.format(new Date(now())); FileSystem localFs = FileSystem.getLocal(conf).getRaw(); File src = null; File dest = null; File srcedit = null; File destedit = null; // // if we are instance one then copy from primary to secondary // otherwise copy from secondary to primary. // if (instance == InstanceId.NODEONE) { src = primary; dest = standby; srcedit = new File(edit0); destedit = new File(edit1); } else if (instance == InstanceId.NODEZERO) { dest = primary; src = standby; destedit = new File(edit0); srcedit = new File(edit1); } // copy fsimage directory if needed if (src.exists() && syncAtStartup) { if (dest.exists()) { File tmp = new File(dest + File.pathSeparator + mdate); if (!dest.renameTo(tmp)) { throw new IOException("Unable to rename " + dest + " to " + tmp); } LOG.info("Moved aside " + dest + " as " + tmp); } if (!FileUtil.copy(localFs, new Path(src.toString()), localFs, new Path(dest.toString()), false, conf)) { msg = "Error copying " + src + " to " + dest; LOG.error(msg); throw new IOException(msg); } LOG.info("Copied " + src + " into " + dest); // Remove the lock file from the newly synced directory File lockfile = new File(dest, STORAGE_FILE_LOCK); lockfile.delete(); // Remove fsimage.ckpt if it exists. File ckptfile = new File(dest.toString() + IMAGENEW); ckptfile.delete(); // Now, copy from the now-updated shared directory to all other // local dirs specified in fs.name.dir src = dest; if (!namedirs.isEmpty()) { for (String str : namedirs) { dest = new File(str); if (dest.exists()) { File tmp = new File(dest + File.pathSeparator + mdate); if (!dest.renameTo(tmp)) { throw new IOException("Unable to rename " + dest + " to " + tmp); } LOG.info("Moved aside " + dest + " as " + tmp); } if (!FileUtil.copy(localFs, new Path(src.toString()), localFs, new Path(dest.toString()), false, conf)) { msg = "Error copying " + src + " to " + dest; LOG.error(msg); throw new IOException(msg); } LOG.info("Copied " + src + " into " + dest); } } } // copy edits directory if needed if (srcedit.exists() && syncAtStartup) { if (destedit.exists()) { File tmp = new File(destedit + File.pathSeparator + mdate); if (!destedit.renameTo(tmp)) { throw new IOException("Unable to rename " + destedit + " to " + tmp); } LOG.info("Moved aside " + destedit + " as " + tmp); } if (!FileUtil.copy(localFs, new Path(srcedit.toString()), localFs, new Path(destedit.toString()), false, conf)) { msg = "Error copying " + srcedit + " to " + destedit; LOG.error(msg); throw new IOException(msg); } LOG.info("Copied " + srcedit + " into " + destedit); // Remove the lock file from the newly synced directory File lockfile = new File(destedit, STORAGE_FILE_LOCK); if (lockfile.delete() == false) { throw new IOException("Unable to delete lock file " + lockfile); } // Remove edits and edits.new. Create empty edits file. File efile = new File(destedit.toString() + EDITSFILE); if (efile.delete() == false) { throw new IOException("Unable to delete edits file " + efile); } efile = new File(destedit + EDITSNEW); efile.delete(); createEditsFile(destedit.toString()); // Now, copy from the now-updated shared directory to all other // local dirs specified in fs.name.edits.dir srcedit = destedit; if (!editsdir.isEmpty()) { for (String str : editsdir) { destedit = new File(str); if (destedit.exists()) { File tmp = new File(destedit + File.pathSeparator + mdate); if (!destedit.renameTo(tmp)) { throw new IOException("Unable to rename " + destedit + " to " + tmp); } LOG.info("Moved aside " + destedit + " as " + tmp); } if (!FileUtil.copy(localFs, new Path(srcedit.toString()), localFs, new Path(destedit.toString()), false, conf)) { msg = "Error copying " + srcedit + " to " + destedit; LOG.error(msg); throw new IOException(msg); } LOG.info("Copied " + srcedit + " into " + destedit); } } } // allocate a new configuration and update fs.name.dir approprately // The shared device should be the first in the list. Configuration newconf = new Configuration(conf); StringBuffer buf = new StringBuffer(); if (instance == InstanceId.NODEONE) { buf.append(img1); } else if (instance == InstanceId.NODEZERO) { buf.append(img0); } for (String str : namedirs) { buf.append(","); buf.append(str); } newconf.set("dfs.name.dir", buf.toString()); buf = null; // update fs.name.edits.dir approprately in the new configuration // The shared device should be the first in the list. StringBuffer buf1 = new StringBuffer(); if (instance == InstanceId.NODEONE) { buf1.append(edit1); } else if (instance == InstanceId.NODEZERO) { buf1.append(edit0); } for (String str : editsdir) { buf1.append(","); buf1.append(str); } newconf.set("dfs.name.edits.dir", buf1.toString()); // if we are starting as the other namenode, then change the // default URL to make the namenode attach to the appropriate URL if (instance == InstanceId.NODEZERO) { String fs = conf.get("fs.default.name0"); if (fs != null) { newconf.set("fs.default.name", fs); } fs = conf.get("dfs.http.address0"); if (fs != null) { newconf.set("dfs.http.address", fs); } fs = conf.get("dfs.namenode.dn-address0"); if (fs != null) { newconf.set("dfs.namenode.dn-address", fs); } } if (instance == InstanceId.NODEONE) { String fs = conf.get("fs.default.name1"); if (fs != null) { newconf.set("fs.default.name", fs); } fs = conf.get("dfs.http.address1"); if (fs != null) { newconf.set("dfs.http.address", fs); } fs = conf.get("dfs.namenode.dn-address1"); if (fs != null) { newconf.set("dfs.namenode.dn-address", fs); } } return newconf; }
From source file:org.codehaus.enunciate.modules.BasicAppModule.java
/** * Copies the classpath elements to WEB-INF. * * @throws java.io.IOException//from www.j a va2 s. c o m */ protected void doLibCopy() throws IOException { Enunciate enunciate = getEnunciate(); File buildDir = getBuildDir(); File webinf = new File(buildDir, "WEB-INF"); File webinfClasses = new File(webinf, "classes"); File webinfLib = new File(webinf, "lib"); //initialize the include filters. AntPatternMatcher pathMatcher = new AntPatternMatcher(); pathMatcher.setPathSeparator(File.separator); List<File> explicitIncludes = new ArrayList<File>(); List<String> includePatterns = new ArrayList<String>(); WebAppConfig webAppConfig = getWebAppConfig(); if (webAppConfig != null) { for (IncludeExcludeLibs el : webAppConfig.getIncludeLibs()) { if (el.getFile() != null) { //add explicit files to the include files list. explicitIncludes.add(el.getFile()); } String pattern = el.getPattern(); if (pattern != null) { //normalize the pattern to the platform. pattern = pattern.replace('/', File.separatorChar); if (pathMatcher.isPattern(pattern)) { //make sure that the includes pattern list only has patterns. includePatterns.add(pattern); } else { warn("Pattern '%s' is not a valid pattern, so it will not be applied.", pattern); } } } } if (includePatterns.isEmpty()) { //if no include patterns are specified, the implicit pattern is "**/*". String starPattern = "**" + File.separatorChar + "*"; debug("No include patterns have been specified. Using the implicit '%s' pattern.", starPattern); includePatterns.add(starPattern); } List<String> warLibs = new ArrayList<String>(); if (webAppConfig == null || webAppConfig.isIncludeClasspathLibs()) { debug("Using the Enunciate classpath as the initial list of libraries to be passed through the include/exclude filter."); //prime the list of libs to include in the war with what's on the enunciate classpath. warLibs.addAll(Arrays.asList(enunciate.getEnunciateRuntimeClasspath().split(File.pathSeparator))); } // Apply the "in filter" (i.e. the filter that specifies the files to be included). List<File> includedLibs = new ArrayList<File>(); for (String warLib : warLibs) { File libFile = new File(warLib); if (libFile.exists()) { for (String includePattern : includePatterns) { String absolutePath = libFile.getAbsolutePath(); if (absolutePath.startsWith(File.separator)) { //lob off the beginning "/" for Linux boxes. absolutePath = absolutePath.substring(1); } if (pathMatcher.match(includePattern, absolutePath)) { debug("Library '%s' passed the include filter. It matches pattern '%s'.", libFile.getAbsolutePath(), includePattern); includedLibs.add(libFile); break; } else if (enunciate.isDebug()) { debug("Library '%s' did NOT match include pattern '%s'.", includePattern); } } } } //Now, with what's left, apply the "exclude filter". boolean excludeDefaults = webAppConfig == null || webAppConfig.isExcludeDefaultLibs(); List<String> manifestClasspath = new ArrayList<String>(); Iterator<File> toBeIncludedIt = includedLibs.iterator(); while (toBeIncludedIt.hasNext()) { File toBeIncluded = toBeIncludedIt.next(); if (excludeDefaults && knownExclude(toBeIncluded)) { toBeIncludedIt.remove(); } else if (webAppConfig != null) { for (IncludeExcludeLibs excludeLibs : webAppConfig.getExcludeLibs()) { boolean exclude = false; if ((excludeLibs.getFile() != null) && (excludeLibs.getFile().equals(toBeIncluded))) { exclude = true; debug("%s was explicitly excluded.", toBeIncluded); } else { String pattern = excludeLibs.getPattern(); if (pattern != null) { pattern = pattern.replace('/', File.separatorChar); if (pathMatcher.isPattern(pattern)) { String absolutePath = toBeIncluded.getAbsolutePath(); if (absolutePath.startsWith(File.separator)) { //lob off the beginning "/" for Linux boxes. absolutePath = absolutePath.substring(1); } if (pathMatcher.match(pattern, absolutePath)) { exclude = true; debug("%s was excluded because it matches pattern '%s'", toBeIncluded, pattern); } } } } if (exclude) { toBeIncludedIt.remove(); if ((excludeLibs.isIncludeInManifest()) && (!toBeIncluded.isDirectory())) { //include it in the manifest anyway. manifestClasspath.add(toBeIncluded.getName()); debug("'%s' will be included in the manifest classpath.", toBeIncluded.getName()); } break; } } } } //now add the lib files that are explicitly included. includedLibs.addAll(explicitIncludes); //now we've got the final list, copy the libs. for (File includedLib : includedLibs) { if (includedLib.isDirectory()) { debug("Adding the contents of %s to WEB-INF/classes.", includedLib); enunciate.copyDir(includedLib, webinfClasses); } else { debug("Including %s in WEB-INF/lib.", includedLib); enunciate.copyFile(includedLib, includedLib.getParentFile(), webinfLib); } } // write the manifest file. Manifest manifest = webAppConfig == null ? WebAppConfig.getDefaultManifest() : webAppConfig.getManifest(); if ((manifestClasspath.size() > 0) && (manifest.getMainAttributes().getValue("Class-Path") == null)) { StringBuilder manifestClasspathValue = new StringBuilder(); Iterator<String> manifestClasspathIt = manifestClasspath.iterator(); while (manifestClasspathIt.hasNext()) { String entry = manifestClasspathIt.next(); manifestClasspathValue.append(entry); if (manifestClasspathIt.hasNext()) { manifestClasspathValue.append(" "); } } manifest.getMainAttributes().putValue("Class-Path", manifestClasspathValue.toString()); } File metaInf = new File(buildDir, "META-INF"); metaInf.mkdirs(); FileOutputStream manifestFileOut = new FileOutputStream(new File(metaInf, "MANIFEST.MF")); manifest.write(manifestFileOut); manifestFileOut.flush(); manifestFileOut.close(); }
From source file:org.kalypso.commons.java.io.FileUtilities.java
public static File findExecutableOnPath(final String executableName) { final String systemPath = System.getenv("PATH"); //$NON-NLS-1$ final String[] pathDirs = systemPath.split(File.pathSeparator); for (final String pathDir : pathDirs) { final File file = new File(pathDir, executableName); if (file.isFile()) return file; }//from www . ja va2s .c o m // not found on path return null; }
From source file:cl.utfsm.cdbChecker.CDBChecker.java
/** * Main function to run the cdbChecker tool. * System.exit(0/1) is used to return success if everything if fine or * failure in case errors were encountered. *///w w w . ja v a 2s. co m public static void main(String[] args) { Logger logger = ClientLogManager.getAcsLogManager() .getLoggerForApplication(CDBChecker.class.getSimpleName(), false); CDBChecker cdbchecker = new CDBChecker(logger); cdbchecker.props = System.getProperties(); /* Blank lines to see the output clearly */ System.out.println("\n\n"); /* * Retrieves the CDB path from the property, if given */ String ACS_cdbpath = cdbchecker.props.getProperty("ACS.cdbpath"); /* * Check for Paths and flags received from command line * and sets accordiningly member variables. * These non explicit side effects should be avoided. */ if (cdbchecker.checkArgs(args)) { //add panta@naoj 2009/10/05 String pathsMulti[] = cdbchecker.XMLPath.split(File.pathSeparator); for (int i = 0; i < pathsMulti.length; i++) { File file_ = new File(pathsMulti[i]); if (!file_.exists()) { System.out.println("*** ImplLang Check: Specified path " + file_ + " does not exist"); cdbchecker.setGlobalErrorFlag(true); cdbchecker.showEndResult(); break; } } //add panta@naoj 2009/10/05 end //Creating the parser // System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"); cdbchecker.SP = new SAXParser(); cdbchecker.xsd_targetns = new Hashtable<String, String>(); //Download the required Schemas if (cdbchecker.verbose) { System.out.println("*** Reading required schema files"); } if (cdbchecker.configLoader()) { if (cdbchecker.verbose) { System.out.println("*** Reading given schema files"); } // Appends command line schema files, if any if (ACS_cdbpath != null) { // We assume that cdbchecker.XSDPath is at least initialised to the empty string and never null // Modify panta@naoj 2009/10/15 if (cdbchecker.XSDPath == null) { cdbchecker.XSDPath = ACS_cdbpath; } else { cdbchecker.XSDPath = cdbchecker.XSDPath + ":" + ACS_cdbpath; } } if (cdbchecker.checkidl) { if (cdbchecker.verbose) { System.out.println("*** Checking Idl Types"); } cdbchecker.checkIdlTypes(); } String paths[] = cdbchecker.XSDPath.split(File.pathSeparator); Vector<String> xsdFilenames = cdbchecker.getFilenames(paths, "xsd"); if (cdbchecker.verbose) System.out.println("*** Reading given XML files"); // We assume that cdbchecker.XMLPath is at least // initialised to the empty string and never null paths = cdbchecker.XMLPath.split(File.pathSeparator); Vector<String> XMLFilenames = cdbchecker.getFilenames(paths, "xml"); // Fill the map with the targetNamespace and the filenames if (cdbchecker.verbose) System.out.println("*** Getting TargetNamespaces from schema files"); cdbchecker.getTargetNamespace(xsdFilenames); // Validating Schemas if (cdbchecker.verbose) System.out.println("*** Validating Schemas"); cdbchecker.validateSchemas(xsdFilenames); // Validating XML files if (cdbchecker.verbose) System.out.println("*** Validating XML files"); cdbchecker.XMLValidate(XMLFilenames); // add panta@naoj 2009/10/05 // checks if implLang matches, those written in XXComponents.xml and XXContainers.xml for (int i = 0; i < pathsMulti.length; i++) { cdbchecker.componentsFolder = pathsMulti[i] + File.separator + "MACI" + File.separator + "Components"; cdbchecker.containersFolder = pathsMulti[i] + File.separator + "MACI" + File.separator + "Containers"; File compFolder = new File(cdbchecker.componentsFolder); File contFolder = new File(cdbchecker.containersFolder); // System.out.println("compFolder: " + compFolder); // System.out.println("contFolder: " + contFolder); if (compFolder.exists() && contFolder.exists()) { cdbchecker.setGlobalErrorFlag(cdbchecker.checkImplLangMatch(compFolder, contFolder)); // exit if error if (cdbchecker.isGlobalErrorFlag()) { break; } } } // add panta@naoj 2009/10/05 end } } else { printUsage(); } cdbchecker.cleanUp(); cdbchecker.showEndResult(); }
From source file:com.amaze.filemanager.activities.MainActivity.java
/** * Returns all available SD-Cards in the system (include emulated) * <p>/* ww w. j a va2 s. co m*/ * Warning: Hack! Based on Android source code of version 4.3 (API 18) * Because there is no standard way to get it. * TODO: Test on future Android versions 4.4+ * * @return paths to all available SD-Cards in the system (include emulated) */ public List<String> getStorageDirectories() { // Final set of paths final ArrayList<String> rv = new ArrayList<>(); // Primary physical SD-CARD (not emulated) final String rawExternalStorage = System.getenv("EXTERNAL_STORAGE"); // All Secondary SD-CARDs (all exclude primary) separated by ":" final String rawSecondaryStoragesStr = System.getenv("SECONDARY_STORAGE"); // Primary emulated SD-CARD final String rawEmulatedStorageTarget = System.getenv("EMULATED_STORAGE_TARGET"); if (TextUtils.isEmpty(rawEmulatedStorageTarget)) { // Device has physical external storage; use plain paths. if (TextUtils.isEmpty(rawExternalStorage)) { // EXTERNAL_STORAGE undefined; falling back to default. rv.add("/storage/sdcard0"); } else { rv.add(rawExternalStorage); } } else { // Device has emulated storage; external storage paths should have // userId burned into them. final String rawUserId; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { rawUserId = ""; } else { final String path = Environment.getExternalStorageDirectory().getAbsolutePath(); final String[] folders = DIR_SEPARATOR.split(path); final String lastFolder = folders[folders.length - 1]; boolean isDigit = false; try { Integer.valueOf(lastFolder); isDigit = true; } catch (NumberFormatException ignored) { } rawUserId = isDigit ? lastFolder : ""; } // /storage/emulated/0[1,2,...] if (TextUtils.isEmpty(rawUserId)) { rv.add(rawEmulatedStorageTarget); } else { rv.add(rawEmulatedStorageTarget + File.separator + rawUserId); } } // Add all secondary storages if (!TextUtils.isEmpty(rawSecondaryStoragesStr)) { // All Secondary SD-CARDs splited into array final String[] rawSecondaryStorages = rawSecondaryStoragesStr.split(File.pathSeparator); Collections.addAll(rv, rawSecondaryStorages); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkStoragePermission()) rv.clear(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { String strings[] = FileUtil.getExtSdCardPathsForActivity(this); for (String s : strings) { File f = new File(s); if (!rv.contains(s) && utils.canListFiles(f)) rv.add(s); } } rootmode = Sp.getBoolean("rootmode", false); if (rootmode) rv.add("/"); File usb = getUsbDrive(); if (usb != null && !rv.contains(usb.getPath())) rv.add(usb.getPath()); return rv; }
From source file:org.jboss.as.test.integration.management.cli.ModuleTestCase.java
private File getModulePath() { String modulePath = TestSuiteEnvironment.getSystemProperty("module.path", null); if (modulePath == null) { String jbossHome = TestSuiteEnvironment.getSystemProperty("jboss.dist", null); if (jbossHome == null) { throw new IllegalStateException("Neither -Dmodule.path nor -Djboss.home were set"); }//from w ww .j av a 2 s. com 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:org.apache.oozie.action.hadoop.SparkMain.java
private void appendWithPathSeparator(String what, StringBuilder to) { if (to.length() > 0) { to.append(File.pathSeparator); } to.append(what); }