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:com.github.maven_nar.NarUtil.java
public static String addLibraryPathToEnv(final String path, final Map environment, final String os) { String pathName = null;//from ww w. jav a2s. co m char separator = ' '; switch (os) { case OS.WINDOWS: pathName = "PATH"; separator = ';'; break; case OS.MACOSX: pathName = "DYLD_LIBRARY_PATH"; separator = ':'; break; case OS.AIX: pathName = "LIBPATH"; separator = ':'; break; default: pathName = "LD_LIBRARY_PATH"; separator = ':'; break; } String value = environment != null ? (String) environment.get(pathName) : null; if (value == null) { value = NarUtil.getEnv(pathName, pathName, null); } String libPath = path; libPath = libPath.replace(File.pathSeparatorChar, separator); if (value != null) { value += separator + libPath; } else { value = libPath; } if (environment != null) { environment.put(pathName, value); } return pathName + "=" + value; }
From source file:com.igormaznitsa.sciareto.preferences.FileHistoryManager.java
@Nonnull @MustNotContainNull// ww w . j a va 2 s . c o m public File[] getActiveProjects() throws IOException { final String activeProjectsStr = PreferencesManager.getInstance().getPreferences().get(ACTIVE_PROJECTS, null); final File[] result; if (activeProjectsStr == null) { result = new File[0]; } else { final List<File> list = new ArrayList<>(); fillList(decodeString(activeProjectsStr).split("\\" + File.pathSeparatorChar), list); result = list.toArray(new File[list.size()]); } return result; }
From source file:de.thetaphi.forbiddenapis.CliMain.java
@SuppressWarnings({ "static-access", "static" }) public CliMain(String... args) throws ExitException { final OptionGroup required = new OptionGroup(); required.setRequired(true);// w ww .j a va2s .c o m required.addOption(dirOpt = OptionBuilder.withDescription( "directory with class files to check for forbidden api usage; this directory is also added to classpath") .withLongOpt("dir").hasArg().withArgName("directory").create('d')); required.addOption(versionOpt = OptionBuilder.withDescription("print product version and exit") .withLongOpt("version").create('V')); required.addOption( helpOpt = OptionBuilder.withDescription("print this help").withLongOpt("help").create('h')); final Options options = new Options(); options.addOptionGroup(required); options.addOption(classpathOpt = OptionBuilder .withDescription("class search path of directories and zip/jar files").withLongOpt("classpath") .hasArgs().withValueSeparator(File.pathSeparatorChar).withArgName("path").create('c')); options.addOption(includesOpt = OptionBuilder.withDescription( "ANT-style pattern to select class files (separated by commas or option can be given multiple times, defaults to '**/*.class')") .withLongOpt("includes").hasArgs().withValueSeparator(',').withArgName("pattern").create('i')); options.addOption(excludesOpt = OptionBuilder.withDescription( "ANT-style pattern to exclude some files from checks (separated by commas or option can be given multiple times)") .withLongOpt("excludes").hasArgs().withValueSeparator(',').withArgName("pattern").create('e')); options.addOption(signaturesfileOpt = OptionBuilder .withDescription("path to a file containing signatures (option can be given multiple times)") .withLongOpt("signaturesfile").hasArg().withArgName("file").create('f')); options.addOption(bundledsignaturesOpt = OptionBuilder.withDescription( "name of a bundled signatures definition (separated by commas or option can be given multiple times)") .withLongOpt("bundledsignatures").hasArgs().withValueSeparator(',').withArgName("name") .create('b')); options.addOption(suppressannotationsOpt = OptionBuilder.withDescription( "class name or glob pattern of annotation that suppresses error reporting in classes/methods/fields (separated by commas or option can be given multiple times)") .withLongOpt("suppressannotation").hasArgs().withValueSeparator(',').withArgName("classname") .create()); options.addOption(internalruntimeforbiddenOpt = OptionBuilder .withDescription("forbids calls to classes from the internal java runtime (like sun.misc.Unsafe)") .withLongOpt("internalruntimeforbidden").create()); options.addOption(allowmissingclassesOpt = OptionBuilder .withDescription("don't fail if a referenced class is missing on classpath") .withLongOpt("allowmissingclasses").create()); options.addOption(allowunresolvablesignaturesOpt = OptionBuilder .withDescription("don't fail if a signature is not resolving") .withLongOpt("allowunresolvablesignatures").create()); try { this.cmd = new PosixParser().parse(options, args); if (cmd.hasOption(helpOpt.getLongOpt())) { printHelp(options); throw new ExitException(EXIT_SUCCESS); } if (cmd.hasOption(versionOpt.getLongOpt())) { printVersion(); throw new ExitException(EXIT_SUCCESS); } } catch (org.apache.commons.cli.ParseException pe) { printHelp(options); throw new ExitException(EXIT_ERR_CMDLINE); } }
From source file:com.yfiton.oauth.receiver.GraphicalReceiver.java
private String getClasspath() { StringBuilder result = new StringBuilder(); for (URL url : ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs()) { result.append(new File(url.getPath())); result.append(File.pathSeparatorChar); }/* www . jav a2 s . c o m*/ return result.toString(); }
From source file:de.thetaphi.forbiddenapis.cli.CliMain.java
public CliMain(String... args) throws ExitException { final OptionGroup required = new OptionGroup(); required.setRequired(true);//from w w w .j a v a 2 s. co m required.addOption(dirOpt = Option.builder("d").desc( "directory with class files to check for forbidden api usage; this directory is also added to classpath") .longOpt("dir").hasArg().argName("directory").build()); required.addOption( versionOpt = Option.builder("V").desc("print product version and exit").longOpt("version").build()); required.addOption(helpOpt = Option.builder("h").desc("print this help").longOpt("help").build()); final Options options = new Options(); options.addOptionGroup(required); options.addOption(classpathOpt = Option.builder("c") .desc("class search path of directories and zip/jar files").longOpt("classpath").hasArgs() .valueSeparator(File.pathSeparatorChar).argName("path").build()); options.addOption(includesOpt = Option.builder("i").desc( "ANT-style pattern to select class files (separated by commas or option can be given multiple times, defaults to '**/*.class')") .longOpt("includes").hasArgs().valueSeparator(',').argName("pattern").build()); options.addOption(excludesOpt = Option.builder("e").desc( "ANT-style pattern to exclude some files from checks (separated by commas or option can be given multiple times)") .longOpt("excludes").hasArgs().valueSeparator(',').argName("pattern").build()); options.addOption(signaturesfileOpt = Option.builder("f") .desc("path to a file containing signatures (option can be given multiple times)") .longOpt("signaturesfile").hasArg().argName("file").build()); options.addOption(bundledsignaturesOpt = Option.builder("b").desc( "name of a bundled signatures definition (separated by commas or option can be given multiple times)") .longOpt("bundledsignatures").hasArgs().valueSeparator(',').argName("name").build()); options.addOption(suppressannotationsOpt = Option.builder().desc( "class name or glob pattern of annotation that suppresses error reporting in classes/methods/fields (separated by commas or option can be given multiple times)") .longOpt("suppressannotation").hasArgs().valueSeparator(',').argName("classname").build()); options.addOption(internalruntimeforbiddenOpt = Option.builder().desc(String.format(Locale.ENGLISH, "DEPRECATED: forbids calls to non-portable runtime APIs; use bundled signatures '%s' instead", BS_JDK_NONPORTABLE)).longOpt("internalruntimeforbidden").build()); options.addOption(allowmissingclassesOpt = Option.builder() .desc("don't fail if a referenced class is missing on classpath").longOpt("allowmissingclasses") .build()); options.addOption(allowunresolvablesignaturesOpt = Option.builder() .desc("don't fail if a signature is not resolving").longOpt("allowunresolvablesignatures").build()); try { this.cmd = new DefaultParser().parse(options, args); if (cmd.hasOption(helpOpt.getLongOpt())) { printHelp(options); throw new ExitException(EXIT_SUCCESS); } if (cmd.hasOption(versionOpt.getLongOpt())) { printVersion(); throw new ExitException(EXIT_SUCCESS); } } catch (org.apache.commons.cli.ParseException pe) { printHelp(options); throw new ExitException(EXIT_ERR_CMDLINE); } }
From source file:org.openecomp.sdc.validation.impl.UploadValidationManagerImpl.java
private static int lastIndexFileSeparatorIndex(String filePath) { int length = filePath.length() - 1; for (int i = length; i >= 0; i--) { char currChar = filePath.charAt(i); if (currChar == '/' || currChar == File.separatorChar || currChar == File.pathSeparatorChar) { return i; }/* w ww. j a va 2 s. c om*/ } // if we've reached to the start of the string and didn't find file separator - return -1 return -1; }
From source file:org.webcat.plugintester.ui.PluginsTableModel.java
public void updatePropertiesFromModel(Properties props) { StringBuffer buffer = new StringBuffer(); if (plugins.size() > 0) { buffer.append(plugins.get(0));/* w w w .jav a 2s .com*/ for (int i = 1; i < plugins.size(); i++) { buffer.append(File.pathSeparatorChar); buffer.append(plugins.get(i)); } } props.setProperty(AppConstants.PROP_LAST_PLUGIN_PATHS, buffer.toString()); }
From source file:com.igormaznitsa.sciareto.preferences.FileHistoryManager.java
@Nonnull @MustNotContainNull/*from w ww . j a va 2 s . c o m*/ public File[] getActiveFiles() throws IOException { final String activeProjectsStr = PreferencesManager.getInstance().getPreferences().get(ACTIVE_FILES, null); final File[] result; if (activeProjectsStr == null) { result = new File[0]; } else { final List<File> list = new ArrayList<>(); fillList(decodeString(activeProjectsStr).split("\\" + File.pathSeparatorChar), list); result = list.toArray(new File[list.size()]); } return result; }
From source file:org.gradle.api.internal.file.FileNormaliser.java
boolean isNormalisingRequiredForAbsolutePath(String filePath) { if (File.pathSeparatorChar != '/') { filePath = filePath.replace(File.pathSeparatorChar, '/'); }/*from w w w . j a v a 2 s . c o m*/ if (filePath.charAt(0) != '/') { throw new IllegalArgumentException( "Only absolute unix paths are currently handled. filePath=" + filePath); } if (filePath.contains("/../") || filePath.contains("/./") || filePath.contains("//")) { return true; } if (filePath.endsWith("/") || filePath.endsWith("/.") || filePath.endsWith("/..")) { return true; } return false; }
From source file:com.googlecode.jsonschema2pojo.integration.util.CodeGenerationHelper.java
public static ClassLoader compile(File sourceDirectory, List<String> classpath) { List<String> fullClasspath = new ArrayList<String>(); fullClasspath.addAll(classpath);/*ww w . j a va 2s.c om*/ fullClasspath.add(System.getProperty("java.class.path")); new Compiler().compile(sourceDirectory, join(fullClasspath, File.pathSeparatorChar)); try { return URLClassLoader.newInstance(new URL[] { sourceDirectory.toURI().toURL() }, Thread.currentThread().getContextClassLoader()); } catch (MalformedURLException e) { throw new RuntimeException(e); } }