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:com.aliyun.openservices.odps.console.ODPSConsole.java
private static void checkSDKEnviron() { String classpath = System.getProperty("java.class.path"); String[] classpathEntries = classpath.split(File.pathSeparator); long count = 0L; for (String line : classpathEntries) { if (line.contains("odps-sdk-core") && (!line.contains("odps-sdk-core-internal"))) { ++count;//from w ww. j a va2 s . c om } } if (count > 1) { System.err.println( "WARNING: detected sdk conflict in console lib folder. Please install console in a fresh new folder."); } }
From source file:org.codehaus.mojo.jspc.compiler.glassfish3.JspCompilerImpl.java
public void setClasspath(Iterable<String> classpathElements) { final String classpath = StringUtils.join(classpathElements.iterator(), File.pathSeparator); jspc.setClassPath(classpath);/*from www. j a v a 2s.com*/ }
From source file:org.jruyi.cli.Main.java
private static File[] getLibJars() throws Throwable { File homeDir;//w ww . j av a 2 s .c o m String temp = System.getProperty("jruyi.home.dir"); if (temp == null) { String classpath = System.getProperty("java.class.path"); int index = classpath.toLowerCase().indexOf("jruyi-cli"); int start = classpath.lastIndexOf(File.pathSeparator, index) + 1; if (index >= start) { temp = classpath.substring(start, index); homeDir = new File(temp).getCanonicalFile().getParentFile(); } else // use current dir homeDir = new File(System.getProperty("user.dir")); } else homeDir = new File(temp); homeDir = homeDir.getCanonicalFile(); return new File(homeDir, "lib").listFiles(new JarFileFilter()); }
From source file:net.sf.firemox.deckbuilder.BuildBook.java
BuildBook() { cachedImageDirStore = "src/main/resources/tbs/mtg/images/gp"; dedfaultImage = cachedImageDirStore + File.pathSeparator + "magic_the_gathering.jpg"; cachedImageDir = new ArrayList<String>(); cachedImageDir.add(cachedImageDirStore); // cachedImageDir.add("src/main/resources/tbs/mtg/images"); imageSources = new ArrayList<String>(); imageSources.add("http://www.wizards.com/global/images/magic/general/{name}.jpg"); checklist = "etc/cardlists/list-gp.txt"; pdfBook = "etc/pdf/Guildpact.pdf"; basicLands = new HashMap<String, Integer>(); basicLands.put("Forest", 1); basicLands.put("Island", 1); basicLands.put("Swamp", 1); basicLands.put("Plains", 1); basicLands.put("Mountain", 1); }
From source file:ClassPath.java
private static final void getPathComponents(String path, List list) { if (path != null) { StringTokenizer tok = new StringTokenizer(path, File.pathSeparator); while (tok.hasMoreTokens()) { String name = tok.nextToken(); File file = new File(name); if (file.exists()) { list.add(name);// ww w.j ava 2 s .c o m } } } }
From source file:org.apache.hadoop.hdfs.server.namenode.StandbyStorageRetentionManager.java
/** * Backup given directory.//w ww.j av a 2 s . c om * Enforce that max number of backups has not been reached. */ static void backupFiles(FileSystem fs, File dest, Configuration conf) throws IOException { // check if we can still backup cleanUpAndCheckBackup(conf, dest); int MAX_ATTEMPT = 3; for (int i = 0; i < MAX_ATTEMPT; i++) { try { String mdate = dateForm.format(new Date(AvatarNode.now())); 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); } return; } catch (IOException e) { LOG.error("Creating backup exception. Will retry ", e); try { Thread.sleep(1000); } catch (InterruptedException iex) { throw new IOException(iex); } } } throw new IOException("Cannot create backup for: " + dest); }
From source file:avantssar.aslanpp.testing.DiskSpecificationsProvider.java
public DiskSpecificationsProvider(String baseDirectory) { File base = new File(baseDirectory); if (!base.exists() || !base.isDirectory()) { throw new IllegalArgumentException( "Path '" + baseDirectory + "' cannot be accessed or does not point to a directory."); }//from w w w. j a va 2 s .co m IOFileFilter filter = FileFilterUtils.suffixFileFilter(".aslan++"); IOFileFilter dirFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null)); Collection<File> specs = FileUtils.listFiles(base, filter, dirFilter); List<String> forSort = new ArrayList<String>(); SortedSet<String> forASLanPath = new TreeSet<String>(); for (File f : specs) { if (isSpec(f)) { forSort.add(f.getAbsolutePath()); forASLanPath.add(f.getParent()); } } Collections.sort(forSort); for (String s : forSort) { add(new DiskTestTask(new File(s))); } String temp = ""; for (String s : forASLanPath) { if (temp.length() > 0) { temp += File.pathSeparator; } temp += s; } aslanPath = temp; }
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. */// www. j a v a2 s . c o 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:org.apache.sqoop.utils.TestConnectorClassLoader.java
@Test public void testConstructUrlsFromClasspath() throws Exception { File file = new File(testDir, "file"); assertTrue(file.createNewFile(), "Create file"); File dir = new File(testDir, "dir"); assertTrue(dir.mkdir(), "Make dir"); File jarsDir = new File(testDir, "jarsdir"); assertTrue(jarsDir.mkdir(), "Make jarsDir"); File nonJarFile = new File(jarsDir, "nonjar"); assertTrue(nonJarFile.createNewFile(), "Create non-jar file"); File jarFile = new File(jarsDir, "a.jar"); assertTrue(jarFile.createNewFile(), "Create jar file"); File nofile = new File(testDir, "nofile"); // don't create nofile StringBuilder cp = new StringBuilder(); cp.append(file.getAbsolutePath()).append(File.pathSeparator).append(dir.getAbsolutePath()) .append(File.pathSeparator).append(jarsDir.getAbsolutePath() + "/*").append(File.pathSeparator) .append(nofile.getAbsolutePath()).append(File.pathSeparator).append(nofile.getAbsolutePath() + "/*") .append(File.pathSeparator); URL[] urls = constructUrlsFromClasspath(cp.toString()); assertEquals(3, urls.length);//w ww. j a v a 2 s.co m assertEquals(file.toURI().toURL(), urls[0]); assertEquals(dir.toURI().toURL(), urls[1]); assertEquals(jarFile.toURI().toURL(), urls[2]); // nofile should be ignored }
From source file:org.alfresco.util.OpenOfficeVariant.java
private File findExecutableOnPath(String executableName) { String systemPath = System.getenv("PATH"); systemPath = systemPath == null ? System.getenv("path") : systemPath; String[] pathDirs = systemPath.split(File.pathSeparator); File fullyQualifiedExecutable = null; for (String pathDir : pathDirs) { File file = canExecute(new File(pathDir, executableName)); if (file != null) { fullyQualifiedExecutable = file; break; }/* w w w . j a va 2 s . c om*/ } return fullyQualifiedExecutable; }