List of usage examples for java.io File separatorChar
char separatorChar
To view the source code for java.io File separatorChar.
Click Source Link
From source file:eu.scidipes.toolkits.pawebapp.web.AdminController.java
@RequestMapping("/templates/deletebundle") public String deleteTemplateBundle(final String bundleName, final RedirectAttributes redirectAttrs) { final Long datasetCount = datasetRepo.countDatasetsByBundle(bundleName); if (datasetCount.longValue() > 0) { LOG.info("Cannot delete bundle '{}' in use by {} datasets", bundleName, datasetCount.toString()); redirectAttrs.addFlashAttribute("errorKey", DELETE_FAIL_IN_USE); return "redirect:/admin/templates/"; }//from ww w . ja v a 2 s . c o m boolean success = false; try { final FormsBundle bundleToDelete = libraryAPI.getEmptyStructureForBundle(bundleName); /* Attempt to delete the template source file first: */ final String processorName = bundleToDelete.getProcessorName(); final PreservationDatasourceProcessor processor = SourceProcessorManager.INSTANCE.getProcessors() .get(processorName); final StringBuilder sourcePath = new StringBuilder(); sourcePath.append(SOURCE_ROOT_PATH + File.separatorChar); sourcePath.append(processor.getClass().getSimpleName() + File.separatorChar); sourcePath.append(bundleToDelete.getTemplateSource()); final File source = new File(sourcePath.toString()); if (source.delete()) { LOG.info("Successfully deleted source file: {}", source); success = libraryAPI.deleteBundle(bundleToDelete); } } catch (final PreservationException e) { LOG.error(e.toString(), e); } if (success) { LOG.info("Successfully deleted bundle: {}", bundleName); redirectAttrs.addFlashAttribute("msgKey", DELETE_SUCCESS); return "redirect:/admin/templates/"; } else { redirectAttrs.addFlashAttribute("errorKey", DELETE_FAIL); return "redirect:/admin/templates/"; } }
From source file:com.sshtools.j2ssh.util.DynamicClassLoader.java
/** * * * @param name// ww w. ja v a 2s . com * * @return */ public URL getResource(String name) { URL u = getSystemResource(name); if (u != null) { return u; } // Load for it only in directories since no URL can point into // a zip file. Iterator it = classpath.iterator(); while (it.hasNext()) { File file = (File) it.next(); if (file.isDirectory()) { String fileName = name.replace('/', File.separatorChar); File resFile = new File(file, fileName); if (resFile.exists()) { // Build a file:// URL form the file name try { return new URL("file://" + resFile.getAbsolutePath()); } catch (java.net.MalformedURLException badurl) { badurl.printStackTrace(); return null; } } } } // Not found return null; }
From source file:ch.entwine.weblounge.common.url.PathUtils.java
/** * Removes any occurence of double file separators and replaces it with a * single one.//from w w w. jav a 2 s. c o m * * @param path * the path to check * @return the corrected path */ private static String removeDoubleSeparator(String path) { int index = 0; String s = File.separator + File.separatorChar; while ((index = path.indexOf(s, index)) != -1) { path = path.substring(0, index) + path.substring(index + 1); } return path; }
From source file:com.sleepcamel.ifdtoutils.MvnPluginMojo.java
private String fileToClass(File baseDirectory, File file) { String classFilePath = FilenameUtils.removeExtension(file.getPath()).replace(baseDirectory.getPath(), "") .substring(1);//from ww w . j a v a2s .co m String className = classFilePath.replace(File.separatorChar, '.'); while (classFilePath.length() != className.length()) { classFilePath = className; className = classFilePath.replace(File.pathSeparatorChar, '.'); } return className; }
From source file:com.msopentech.odatajclient.engine.AbstractPropertyTest.java
private ODataProperty complex() throws IOException { final InputStream input = getClass().getResourceAsStream(getVersion().name().toLowerCase() + File.separatorChar + "Customer_-10_PrimaryContactInfo." + getSuffix(getFormat())); final ODataProperty property = getClient().getReader().readProperty(input, getFormat()); assertNotNull(property);//from w w w .j a v a 2s . com assertTrue(property.hasComplexValue()); assertEquals(6, property.getComplexValue().size()); ODataProperty comparable; final ODataProperty written = getClient().getReader() .readProperty(getClient().getWriter().writeProperty(property, getFormat()), getFormat()); if (getFormat() == ODataFormat.XML) { comparable = written; } else { // This is needed because type information gets lost with JSON serialization final ODataComplexValue typedValue = new ODataComplexValue(property.getComplexValue().getTypeName()); for (final Iterator<ODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) { final ODataProperty prop = itor.next(); typedValue.add(prop); } comparable = getClient().getObjectFactory().newComplexProperty(written.getName(), typedValue); } assertEquals(property, comparable); return property; }
From source file:forge.properties.ForgeProfileProperties.java
private static String getDir(final Properties props, final String propertyKey, final String defaultVal) { String retDir = props.getProperty(propertyKey, defaultVal).trim(); if (retDir.isEmpty()) { // use default if dir is "defined" as an empty string in the properties file retDir = defaultVal;//from w w w.j a v a 2 s.com } // canonicalize retDir = new File(retDir).getAbsolutePath(); // ensure path ends in a slash if (File.separatorChar == retDir.charAt(retDir.length() - 1)) { return retDir; } return retDir + File.separatorChar; }
From source file:net.cnmconsulting.spring.config.util.FilePBEConfig.java
public FilePBEConfig(String folderName, String token, boolean searchSystemEnvironment) { super();//from www.j av a 2 s . c om this.token = token; this.folderName = folderName; this.searchSystemEnvironment = true; if (searchSystemEnvironment) { String path = resolveSystemProperty(folderName); Assert.notNull(path); path += File.separatorChar + token; setPasswordName(new FileSystemResource(path)); } }
From source file:edu.stanford.muse.launcher.Splash.java
public static Context deployWarAt(String warName, String path) throws IOException, ServletException { // extract the war to tmpdir final URL warUrl = TomcatMain.class.getClassLoader().getResource(warName); if (warUrl == null) { err.println("Sorry! Unable to locate file on classpath: " + warName); return null; }/*w ww .ja va 2 s. c o m*/ InputStream is = warUrl.openStream(); String tmp = System.getProperty("java.io.tmpdir"); String file = tmp + File.separatorChar + warName; err.println("Extracting: " + warName + " to " + file + " is=" + is); File existingFile = new File(file); if (existingFile.exists()) err.println("Existing file: " + file); // if (new File(file).exists()) copy_stream_to_file(is, file); File newFile = new File(file); if (!newFile.exists()) { err.println("Sorry! Unable to copy war file: " + file); return null; } err.println( "Copied muse war file with size " + newFile.length() + " bytes to " + newFile.getAbsolutePath()); // clear the tomcat workdir which unfortunately caches jsp-generated java files sometimes and leads to terribly insiduous bugs. String workDir = tmp + File.separator + "muse" + File.separator + "working"; File workFile = new File(workDir); if (workFile.exists()) { err.println("Tomcat work dir exists: " + workDir); boolean success = deleteDir(new File(workDir)); if (!success) err.println("Warning: unable to clear tomcat work dir " + workDir); else err.println("Cool... able to clear tomcat work dir " + workDir); } else err.println("Good, tomcat work dir does not already exist: " + workDir); return server.addWebapp("/muse", new File(file).getAbsolutePath()); }
From source file:com.photon.phresco.framework.param.impl.IosTargetParameterImpl.java
@Override public PossibleValues getValues(Map<String, Object> paramMap) throws IOException, ParserConfigurationException, SAXException, ConfigurationException, PhrescoException { PossibleValues possibleValues = new PossibleValues(); try {/*w w w. ja va2 s . co m*/ String rootModulePath = ""; String subModuleName = ""; ApplicationInfo applicationInfo = (ApplicationInfo) paramMap.get(KEY_APP_INFO); String rootModule = (String) paramMap.get(KEY_ROOT_MODULE); // String appDirName = applicationInfo.getAppDirName(); if (StringUtils.isNotEmpty(rootModule)) { rootModulePath = Utility.getProjectHome() + rootModule; subModuleName = applicationInfo.getAppDirName(); } else { rootModulePath = Utility.getProjectHome() + applicationInfo.getAppDirName(); } File pomFileLocation = Utility.getPomFileLocation(rootModulePath, subModuleName); // StringBuilder builder = new StringBuilder(Utility.getProjectHome()); // builder.append(appDirName); // builder.append(File.separatorChar); // File pomPath = new File(builder.toString(), Utility.getPomFileName(applicationInfo)); PomProcessor pomProcessor = new PomProcessor(pomFileLocation); File sourceDir = null; String sourceDirectory = pomProcessor.getSourceDirectory(); if (sourceDirectory.startsWith("${project.basedir}")) { sourceDirectory = sourceDirectory.substring("${project.basedir}".length()); sourceDir = new File(pomFileLocation.getParent() + sourceDirectory); } else if (sourceDirectory.startsWith("/source")) { sourceDir = new File(pomFileLocation.getParent() + File.separatorChar + sourceDirectory); } else { String filePath = Utility.getProjectHome() + applicationInfo.getAppDirName(); String srcSplitDir = pomProcessor.getProperty("phresco.split.src.dir"); if (StringUtils.isNotEmpty(srcSplitDir)) { filePath = filePath + File.separator + srcSplitDir; } sourceDir = new File(filePath, sourceDirectory); } FilenameFilter filter = new FileListFilter("", IPHONE_XCODE_WORKSPACE_PROJ_EXTN, IPHONE_XCODE_PROJ_EXTN); File[] listFiles = sourceDir.listFiles(filter); StringBuilder cmdBuilder = new StringBuilder(); cmdBuilder.append(XCODEBUILD_LIST_WORKSPACE_CMD); if (listFiles[0].getName().contains(IPHONE_XCODE_WORKSPACE_PROJ_EXTN)) { cmdBuilder.append(IPHONE_XCODE_WORKSPACE); } else if (listFiles[0].getName().contains(IPHONE_XCODE_PROJ_EXTN)) { cmdBuilder.append(IPHONE_XCODE_PROJECT); } cmdBuilder.append(listFiles[0].getName().replace(" ", "\\ ")); Commandline cl = new Commandline(cmdBuilder.toString()); cl.setWorkingDirectory(sourceDir); Process p = cl.execute(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; boolean isTarget = false; while ((line = reader.readLine()) != null) { if (line.trim().equals(XCODE_PROJECT_TARGETS) || line.trim().equals(XCODE_WORKSPACE_TARGETS)) { // getting only target // For iphone projects both targets and Schemes will be displayed, If target is avilable, take target alone else schemes if (CollectionUtils.isEmpty(possibleValues.getValue())) { isTarget = true; } } else if (line.trim().contains(":")) { // omitt all other configurations isTarget = false; } if (isTarget && StringUtils.isNotEmpty(line) && !line.trim().equals(XCODE_PROJECT_TARGETS) && !line.trim().equals(XCODE_WORKSPACE_TARGETS)) { Value value = new Value(); value.setValue(line.trim()); value.setKey(line.trim()); possibleValues.getValue().add(value); } } } catch (Exception e) { e.printStackTrace(); throw new PhrescoException(e); } return possibleValues; }
From source file:de.helmholtz_muenchen.ibis.utils.abstractNodes.RNode.RNodeModel.java
@Override protected String getScriptPath() { return (super.getScriptPath() + R_SCRIPTS_PATH + File.separatorChar); }