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.twosigma.beaker.scala.util.ScalaEvaluator.java
public void setShellOptions(String cp, String in, String od) throws IOException { if (od == null || od.isEmpty()) { od = FileSystems.getDefault().getPath(System.getenv("beaker_tmp_dir"), "dynclasses", sessionId) .toString();/*from w w w .ja va 2 s. c om*/ } else { od = od.replace("$BEAKERDIR", System.getenv("beaker_tmp_dir")); } // check if we are not changing anything if (currentClassPath.equals(cp) && currentImports.equals(in) && outDir.equals(od)) return; currentClassPath = cp; currentImports = in; outDir = od; if (cp == null || cp.isEmpty()) classPath = new ArrayList<String>(); else classPath = Arrays.asList(cp.split("[\\s" + File.pathSeparatorChar + "]+")); if (imports == null || in.isEmpty()) imports = new ArrayList<String>(); else imports = Arrays.asList(in.split("\\s+")); try { (new File(outDir)).mkdirs(); } catch (Exception e) { } resetEnvironment(); }
From source file:org.gradle.process.internal.JvmOptions.java
public void jvmArgs(Iterable<?> arguments) { for (Object argument : arguments) { String argStr = argument.toString(); if (argStr.equals("-ea") || argStr.equals("-enableassertions")) { assertionsEnabled = true;/*from w w w .jav a 2s . c o m*/ } else if (argStr.equals("-da") || argStr.equals("-disableassertions")) { assertionsEnabled = false; } else if (argStr.startsWith(XMS_PREFIX)) { minHeapSize = argStr.substring(XMS_PREFIX.length()); } else if (argStr.startsWith(XMX_PREFIX)) { maxHeapSize = argStr.substring(XMX_PREFIX.length()); } else if (argStr.startsWith(BOOTCLASSPATH_PREFIX)) { String[] bootClasspath = StringUtils.split(argStr.substring(BOOTCLASSPATH_PREFIX.length()), File.pathSeparatorChar); setBootstrapClasspath((Object[]) bootClasspath); } else if (argStr.startsWith("-D")) { String keyValue = argStr.substring(2); int equalsIndex = keyValue.indexOf("="); if (equalsIndex == -1) { systemProperty(keyValue, ""); } else { systemProperty(keyValue.substring(0, equalsIndex), keyValue.substring(equalsIndex + 1)); } } else { extraJvmArgs.add(argument); } } boolean xdebugFound = false; boolean xrunjdwpFound = false; boolean xagentlibJdwpFound = false; Set<Object> matches = new HashSet<Object>(); for (Object extraJvmArg : extraJvmArgs) { if (extraJvmArg.toString().equals("-Xdebug")) { xdebugFound = true; matches.add(extraJvmArg); } else if (extraJvmArg.toString() .equals("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")) { xrunjdwpFound = true; matches.add(extraJvmArg); } else if (extraJvmArg.toString() .equals("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")) { xagentlibJdwpFound = true; matches.add(extraJvmArg); } } if (xdebugFound && xrunjdwpFound || xagentlibJdwpFound) { debug = true; extraJvmArgs.removeAll(matches); } }
From source file:com.pongasoft.kiwidoc.builder.doclet.SourceCodeParser.java
private void parseSources(LibraryModelBuilder library, String overviewPath, List<String> sourcePath, List<String> dependencies) throws IOException, InternalException { StringWriter errors = new StringWriter(); final PrintWriter errWriter = new PrintWriter(errors); StringWriter warnings = new StringWriter(); final PrintWriter warnWriter = new PrintWriter(warnings); StringWriter notices = new StringWriter(); final PrintWriter noticeWriter = new PrintWriter(notices); final List<String> args = new ArrayList<String>(); if (!dependencies.isEmpty()) { args.add("-classpath"); StringBuilder sb = new StringBuilder(); for (String dependency : dependencies) { if (sb.length() > 0) sb.append(File.pathSeparatorChar); sb.append(dependency);/*from ww w . j a v a 2s . c om*/ } args.add(sb.toString()); } args.addAll(sourcePath); args.add("-private"); args.add("-source"); args.add("1." + computeJdkVersion(library.getJdkVersion())); if (overviewPath != null) { args.add("-overview"); args.add(overviewPath); } int retCode = 0; try { retCode = ReflectUtils.executeWithClassLoader(KiwidocDoclet.class.getClassLoader(), new Callable<Integer>() { public Integer call() throws Exception { return Main.execute("kiwidoc", errWriter, warnWriter, noticeWriter, KiwidocDoclet.class.getName(), args.toArray(new String[args.size()])); } }); } catch (IOException e) { throw e; } catch (Exception e) { throw new InternalException(e); } KiwidocDoclet doclet = KiwidocDoclet.getCurrentKiwidocDoclet(); errWriter.close(); warnWriter.close(); noticeWriter.close(); if (warnings.toString().length() > 0) javadocLog.warn(warnings); if (notices.toString().length() > 0 && log.isDebugEnabled()) { javadocLog.debug(notices); } if (retCode != 0) { if (doclet == null || doclet.getClassModels().size() == 0) throw new IOException(errors.toString()); else log.warn("There were some errors during processing (ignored): " + errors.toString()); } Map<String, UnresolvedType> unresolvedTypes = doclet.getUnresolvedTypes(); if (!unresolvedTypes.isEmpty()) log.warn("Unresolved Types: " + unresolvedTypes.keySet()); library.setOverview(doclet.getOverview()); library.addClasses(doclet.getClassModels()); for (Map.Entry<String, DocModel> entry : doclet.getPackageInfos().entrySet()) { library.setPackageInfo(entry.getKey(), entry.getValue()); } }
From source file:com.twosigma.beaker.scala.evaluator.ScalaEvaluator.java
@Override public void setShellOptions(final KernelParameters kernelParameters) throws IOException { Map<String, Object> params = kernelParameters.getParams(); Collection<String> listOfImports = (Collection<String>) params.get(IMPORTS); Collection<String> listOfClassPath = (Collection<String>) params.get(CLASSPATH); String cp = getAsString(listOfClassPath); String in = getAsString(listOfImports); // check if we are not changing anything if (currentClassPath.equals(cp) && currentImports.equals(in)) return;/* www .j a v a 2s . c o m*/ currentClassPath = cp; currentImports = in; if (cp == null || cp.isEmpty()) classPath = new ArrayList<String>(); else classPath = Arrays.asList(cp.split("[\\s" + File.pathSeparatorChar + "]+")); if (imports == null || in.isEmpty()) imports = new ArrayList<String>(); else imports = Arrays.asList(in.split("\\s+")); resetEnvironment(); }
From source file:hudson.util.ProcessTree.java
/** * Gets the {@link ProcessTree} of the current system * that JVM runs in, or in the worst case return the default one * that's not capable of killing descendants at all. *///from w w w . j av a 2 s . c o m public static ProcessTree get() { if (!enabled) return DEFAULT; try { if (File.pathSeparatorChar == ';') return new Windows(); String os = Util.fixNull(System.getProperty("os.name")); if (os.equals("Linux")) return new Linux(); if (os.equals("SunOS")) return new Solaris(); if (os.equals("Mac OS X")) return new Darwin(); } catch (LinkageError e) { LOGGER.log(Level.WARNING, "Failed to load winp. Reverting to the default", e); enabled = false; } return DEFAULT; }
From source file:org.apache.openmeetings.backup.BackupImport.java
private static File validate(String zipname, File intended) throws IOException { final String intendedPath = intended.getCanonicalPath(); if (File.pathSeparatorChar != '\\' && zipname.indexOf('\\') > -1) { zipname = zipname.replace('\\', '/'); }/*from w w w . ja v a 2 s . co m*/ // for each entry to be extracted File fentry = new File(intended, zipname); final String canonicalPath = fentry.getCanonicalPath(); if (canonicalPath.startsWith(intendedPath)) { return fentry; } else { throw new IllegalStateException("File is outside extraction target directory."); } }
From source file:org.apache.hama.bsp.BSPTaskLauncher.java
private GetContainerStatusesRequest setupContainer(Container allocatedContainer, ContainerManagementProtocol cm, String user, int id) throws IOException, YarnException { LOG.info("Setting up a container for user " + user + " with id of " + id + " and containerID of " + allocatedContainer.getId() + " as " + user); // Now we setup a ContainerLaunchContext ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class); // Set the local resources Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(); LocalResource packageResource = Records.newRecord(LocalResource.class); FileSystem fs = FileSystem.get(conf); Path packageFile = new Path(System.getenv(YARNBSPConstants.HAMA_YARN_LOCATION)); URL packageUrl = ConverterUtils .getYarnUrlFromPath(packageFile.makeQualified(fs.getUri(), fs.getWorkingDirectory())); LOG.info("PackageURL has been composed to " + packageUrl.toString()); try {/*from ww w . j a va 2s. c o m*/ LOG.info("Reverting packageURL to path: " + ConverterUtils.getPathFromYarnURL(packageUrl)); } catch (URISyntaxException e) { LOG.fatal("If you see this error the workarround does not work", e); } packageResource.setResource(packageUrl); packageResource.setSize(Long.parseLong(System.getenv(YARNBSPConstants.HAMA_YARN_SIZE))); packageResource.setTimestamp(Long.parseLong(System.getenv(YARNBSPConstants.HAMA_YARN_TIMESTAMP))); packageResource.setType(LocalResourceType.FILE); packageResource.setVisibility(LocalResourceVisibility.APPLICATION); localResources.put(YARNBSPConstants.APP_MASTER_JAR_PATH, packageResource); Path hamaReleaseFile = new Path(System.getenv(YARNBSPConstants.HAMA_RELEASE_LOCATION)); URL hamaReleaseUrl = ConverterUtils .getYarnUrlFromPath(hamaReleaseFile.makeQualified(fs.getUri(), fs.getWorkingDirectory())); LOG.info("Hama release URL has been composed to " + hamaReleaseUrl.toString()); LocalResource hamaReleaseRsrc = Records.newRecord(LocalResource.class); hamaReleaseRsrc.setResource(hamaReleaseUrl); hamaReleaseRsrc.setSize(Long.parseLong(System.getenv(YARNBSPConstants.HAMA_RELEASE_SIZE))); hamaReleaseRsrc.setTimestamp(Long.parseLong(System.getenv(YARNBSPConstants.HAMA_RELEASE_TIMESTAMP))); hamaReleaseRsrc.setType(LocalResourceType.ARCHIVE); hamaReleaseRsrc.setVisibility(LocalResourceVisibility.APPLICATION); localResources.put(YARNBSPConstants.HAMA_SYMLINK, hamaReleaseRsrc); ctx.setLocalResources(localResources); /* * TODO Package classpath seems not to work if you're in pseudo distributed * mode, because the resource must not be moved, it will never be unpacked. * So we will check if our jar file has the file:// prefix and put it into * the CP directly */ StringBuilder classPathEnv = new StringBuilder(ApplicationConstants.Environment.CLASSPATH.$()) .append(File.pathSeparatorChar).append("./*"); for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(c.trim()); } classPathEnv.append(File.pathSeparator); classPathEnv .append("./" + YARNBSPConstants.HAMA_SYMLINK + "/" + YARNBSPConstants.HAMA_RELEASE_VERSION + "/*"); classPathEnv.append(File.pathSeparator); classPathEnv.append( "./" + YARNBSPConstants.HAMA_SYMLINK + "/" + YARNBSPConstants.HAMA_RELEASE_VERSION + "/lib/*"); Vector<CharSequence> vargs = new Vector<CharSequence>(); vargs.add("${JAVA_HOME}/bin/java"); vargs.add("-cp " + classPathEnv + ""); vargs.add(BSPRunner.class.getCanonicalName()); vargs.add(jobId.getJtIdentifier()); vargs.add(Integer.toString(id)); vargs.add(this.jobFile.makeQualified(fs.getUri(), fs.getWorkingDirectory()).toString()); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/bsp.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/bsp.stderr"); // Get final commmand StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } List<String> commands = new ArrayList<String>(); commands.add(command.toString()); ctx.setCommands(commands); LOG.info("Starting command: " + commands); StartContainerRequest startReq = Records.newRecord(StartContainerRequest.class); startReq.setContainerLaunchContext(ctx); startReq.setContainerToken(allocatedContainer.getContainerToken()); List<StartContainerRequest> list = new ArrayList<StartContainerRequest>(); list.add(startReq); StartContainersRequest requestList = StartContainersRequest.newInstance(list); cm.startContainers(requestList); GetContainerStatusesRequest statusReq = Records.newRecord(GetContainerStatusesRequest.class); List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(allocatedContainer.getId()); statusReq.setContainerIds(containerIds); return statusReq; }
From source file:net.sf.clirr.cli.Clirr.java
private File[] pathToFileArray(String path) { if (path == null) { return new File[0]; }//from ww w. jav a 2 s .c om ArrayList files = new ArrayList(); int pos = 0; while (pos < path.length()) { int colonPos = path.indexOf(File.pathSeparatorChar, pos); if (colonPos == -1) { files.add(new File(path.substring(pos))); break; } files.add(new File(path.substring(pos, colonPos))); pos = colonPos + 1; } return (File[]) files.toArray(new File[files.size()]); }
From source file:jetbrains.exodus.util.ForkSupportIO.java
private static StringBuilder appendClassPath(final File directory, final StringBuilder builder) { for (final File dir : IOUtil.listFiles(directory)) { if (dir.isDirectory()) { if (dir.listFiles(JAR_FILTER).length == 0) { if (builder.length() != 0) { builder.append(File.pathSeparatorChar); }// www. j ava 2 s . c o m builder.append(dir.getPath()); } else { if (builder.length() != 0) { builder.append(File.pathSeparatorChar); } builder.append(dir.getPath()); builder.append(File.separatorChar); builder.append('*'); appendClassPath(dir, builder); } } } return builder; }
From source file:com.sany.application.action.AppcreateAction.java
public String picRefApp(String appInfoId, ModelMap model, HttpServletRequest request) throws Exception { List<WfPic> list = appcreateService.getAllWfPicNoContent(); List<String> pic_selected = appcreateService.getAppSelectedPic(appInfoId); String pic_selected_name = "no"; if (null != pic_selected && pic_selected.size() > 0) { if (null != pic_selected.get(0) && !"".equals(pic_selected.get(0))) { pic_selected_name = pic_selected.get(0); }/* www .ja va2 s . c o m*/ } String contextPath = request.getSession().getServletContext().getRealPath(""); File file = new File(contextPath + File.separatorChar + "application" + File.separatorChar + "app_images"); String files[] = file.list(); //???? if (null != list && list.size() > 0) { for (int i = 0; i < list.size(); i++) { String id = list.get(i).getId(); String name = list.get(i).getName(); boolean flag = false; for (int j = 0; j < files.length; j++) { if (name.equals(files[j])) { flag = true; break; } } if (!flag) { appcreateService.getWfPicById(id, contextPath + File.separatorChar + "application" + File.separatorChar + "app_images" + File.pathSeparatorChar + name); } } model.addAttribute("datas", list); model.addAttribute("appInfoId", appInfoId); model.addAttribute("picSelected", pic_selected_name); } return "path:selectPic"; }