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:edu.stanford.epadd.launcher.Main.java
public static WebAppContext deployWarAt(String warName, String path) throws IOException { // extract the war to tmpdir final URL warUrl = Main.class.getClassLoader().getResource(warName); if (warUrl == null) { System.err.println("Sorry! Unable to locate file on classpath: " + warName); return null; }// ww w. j a v a 2 s .co m InputStream is = warUrl.openStream(); String tmp = System.getProperty("java.io.tmpdir"); String file = tmp + File.separatorChar + warName; System.err.println("Extracting: " + warName + " to " + file + " is=" + is); copy_stream_to_file(is, file); if (!new File(file).exists()) { System.err.println("Sorry! Unable to copy war file: " + file); return null; } WebAppContext webapp = new WebAppContext(); webapp.setContextPath(path); webapp.setWar(file); webapp.setExtractWAR(true); return webapp; }
From source file:ar.com.tadp.xml.rinzo.core.utils.FileUtils.java
public static String fileUrlToPath(String s) { String s1 = s;//from w ww . ja v a 2 s . c o m int i = s.indexOf(':'); int j = s.indexOf('/'); if (i > 0 && (j < 0 || i < j)) { if (!s.startsWith("file:")) throw new IllegalArgumentException("Url must begin with \"file:\""); int k = "file:".length(); int l = s.length(); int i1; for (i1 = 0; k < l && s.charAt(k) == '/'; i1++) k++; if (i1 > 0 && (i1 & 1) == 0) k -= 2; s1 = (File.separatorChar != '/' ? "" : "/") + s.substring(k); } if (File.separatorChar != '/') s1 = s1.replace('/', File.separatorChar); return s1; }
From source file:com.ibm.replication.iidr.metadata.ExportMetadata.java
public ExportMetadata(String[] commandLineArguments) throws ConfigurationException, ExportMetadataParmsException, EmbeddedScriptException, ExportMetadataException, MalformedURLException { System.setProperty("log4j.configuration", new File(".", File.separatorChar + "conf" + File.separatorChar + "log4j.properties").toURI().toURL() .toString());//from w w w . java2 s .c o m // logger = // Logger.getLogger("com.ibm.replication.iidr.metadata.ExportMetadata"); logger = Logger.getLogger(ExportMetadata.class.getName()); PropertiesConfiguration versionInfo = new PropertiesConfiguration( "conf" + File.separator + "version.properties"); logger.info(MessageFormat.format("Version: {0}.{1}.{2}, date: {3}", new Object[] { versionInfo.getString("buildVersion"), versionInfo.getString("buildRelease"), versionInfo.getString("buildMod"), versionInfo.getString("buildDate") })); settings = new Settings("conf" + File.separator + this.getClass().getSimpleName() + ".properties"); parms = new ExportMetadataParms(commandLineArguments); assets = new Assets(); // If the debug option was set, make sure that all debug messages are // logged if (parms.debug) { Logger.getRootLogger().setLevel(Level.DEBUG); } // Collect the metadata collectMetadata(); Utils.writeContentToFile(settings.defaultDataPath + File.separator + parms.datastore + "_assets.xml", assets.toXML()); flows = new Flows(assets); Utils.writeContentToFile(settings.defaultDataPath + File.separator + parms.datastore + "_flow.xml", flows.toXML()); if (!parms.previewOnly) { try { IGCRest igcRest = new IGCRest(settings.isHostName, settings.isPort, settings.isUserName, settings.isPassword, settings.trustSelfSignedCertificates); igcRest.uploadBundleIfMissing(settings.bundleFilePath, parms.updateBundle); igcRest.postAssets(assets.toXML()); igcRest.postFlows(flows.toXML()); } catch (IGCRestException e) { logger.error(MessageFormat.format("REST API call for failed with code {0} and message: {1}", new Object[] { e.httpCode, e.message })); throw new ExportMetadataException(e); } catch (Exception e) { throw new ExportMetadataException(e); } } else { String previewFileName = settings.defaultDataPath + File.separator + parms.datastore + "_ExportMetadata_Preview.txt"; logger.debug(MessageFormat.format("Writing output to {0}", new Object[] { previewFileName })); Utils.writeContentToFile(previewFileName, flows.preview()); } logger.info("Finished exporting the CDC metadata"); }
From source file:com.seer.datacruncher.spring.ExtraCheckCustomCodeValidator.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String code = request.getParameter("value"); String name = request.getParameter("name"); String addReq = request.getParameter("addReq"); //TODO: take the result message from "locale" String result = null;/*ww w. java 2 s. co m*/ ObjectMapper mapper = new ObjectMapper(); ServletOutputStream out = null; response.setContentType("application/json"); out = response.getOutputStream(); if (StringUtils.isEmpty(code) || StringUtils.isEmpty(name)) { result = I18n.getMessage("error.extracheck.invaliddata"); } else { name = name.trim(); if (addReq.equalsIgnoreCase("true")) { ReadList list = checksTypeDao.findCustomCodeByName(name); if (list != null && CollectionUtils.isNotEmpty(list.getResults())) { result = I18n.getMessage("error.extracheck.name.alreadyexist"); out.write(mapper.writeValueAsBytes(result)); out.flush(); out.close(); return null; } } try { File sourceDir = new File(System.getProperty("java.io.tmpdir"), "DataCruncher/src"); sourceDir.mkdirs(); String classNamePack = name.replace('.', File.separatorChar); String srcFilePath = sourceDir + "" + File.separatorChar + classNamePack + ".java"; File sourceFile = new File(srcFilePath); if (sourceFile.exists()) { sourceFile.delete(); } FileUtils.writeStringToFile(new File(srcFilePath), code); DynamicClassLoader dynacode = DynamicClassLoader.getInstance(); dynacode.addSourceDir(sourceDir); CustomCodeValidator customCodeValidator = (CustomCodeValidator) dynacode .newProxyInstance(CustomCodeValidator.class, name); boolean isValid = false; if (customCodeValidator != null) { Class clazz = dynacode.getLoadedClass(name); if (clazz != null) { Class[] interfaces = clazz.getInterfaces(); if (ArrayUtils.isNotEmpty(interfaces)) { for (Class clz : interfaces) { if ((clz.getName().equalsIgnoreCase( "com.seer.datacruncher.utils.validation.SingleValidation"))) { isValid = true; } } } } } if (isValid) { result = "Success"; } else { result = I18n.getMessage("error.extracheck.wrongimpl"); } } catch (Exception e) { result = "Failed. Reason:" + e.getMessage(); } } out.write(mapper.writeValueAsBytes(result)); out.flush(); out.close(); return null; }
From source file:org.rivetlogic.utils.IntegrationUtils.java
public static String convertPath(Path alfPath) { StringBuilder pathBuilder = new StringBuilder(100); if (alfPath != null) { for (Element pElem : alfPath) { String pStr = pElem.getPrefixedString(IntegrationConstants.NAMESPACE_PREFIX_RESOLVER); if (!pStr.startsWith("/")) { for (String prefix : IntegrationConstants.NAMESPACE_PREFIX_RESOLVER.getPrefixes()) { if (pStr.startsWith(prefix)) { pStr = ISO9075.decode(pStr.substring(prefix.length() + 1)); break; }/*from w w w . ja va2 s .com*/ } pathBuilder.append(File.separatorChar); pathBuilder.append(pStr); } } } return pathBuilder.toString(); }
From source file:com.consol.citrus.admin.service.TestCaseServiceImpl.java
@Override public List<TestCaseData> getTests(Project project) { List<TestCaseData> tests = new ArrayList<TestCaseData>(); List<File> testFiles = FileUtils.getTestFiles(getTestDirectory(project)); for (File file : testFiles) { String testName = FilenameUtils.getBaseName(file.getName()); String testPackageName = file.getPath().substring(getTestDirectory(project).length(), file.getPath().length() - file.getName().length()).replace(File.separatorChar, '.'); if (testPackageName.endsWith(".")) { testPackageName = testPackageName.substring(0, testPackageName.length() - 1); }/*from w w w .ja v a 2s. com*/ TestCaseData testCase = new TestCaseData(); testCase.setType(TestCaseType.XML); testCase.setName(testName); testCase.setPackageName(testPackageName); testCase.setFile(file.getParentFile().getAbsolutePath() + File.separator + FilenameUtils.getBaseName(file.getName())); testCase.setLastModified(file.lastModified()); tests.add(testCase); } try { Resource[] javaSources = new PathMatchingResourcePatternResolver().getResources( "file:" + FilenameUtils.separatorsToUnix(getJavaDirectory(project)) + "**/*.java"); for (Resource resource : javaSources) { File file = resource.getFile(); String testName = FilenameUtils.getBaseName(file.getName()); String testPackage = file.getParentFile().getAbsolutePath() .substring(getJavaDirectory(project).length()).replace(File.separatorChar, '.'); if (knownToClasspath(testPackage, testName)) { tests.addAll(getTestCaseInfoFromClass(testPackage, testName, file)); } else { tests.addAll(getTestCaseInfoFromFile(testPackage, testName, file)); } } } catch (IOException e) { log.warn("Failed to read Java source files - list of test cases for this project is incomplete", e); } return tests; }
From source file:com.eviware.soapui.support.Tools.java
public static String getDir(String filePath) { if (filePath == null || filePath.length() == 0) { return filePath; }// w w w . j a va2 s .c om int ix = filePath.lastIndexOf(File.separatorChar); if (ix <= 0) { return filePath; } return ensureDir(filePath.substring(0, ix), ""); }
From source file:com.seer.datacruncher.spring.EventTriggerValidator.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String code = request.getParameter("code"); String name = request.getParameter("name"); String addReq = request.getParameter("addReq"); String result = null;//from w w w . j av a2 s. co m ObjectMapper mapper = new ObjectMapper(); ServletOutputStream out = null; response.setContentType("application/json"); out = response.getOutputStream(); if (StringUtils.isEmpty(code) || StringUtils.isEmpty(name)) { result = I18n.getMessage("error.trigger.invaliddata");//"Failed. Reason:Invalid Data"; } else { name = name.trim(); if (addReq.equalsIgnoreCase("true")) { ReadList list = eventTriggerDao.findTriggersByName(name); if (list != null && CollectionUtils.isNotEmpty(list.getResults())) { result = I18n.getMessage("error.trigger.name.alreadyexist");//"Failed. Reason:Name alredy exist"; out.write(mapper.writeValueAsBytes(result)); out.flush(); out.close(); return null; } } try { File sourceDir = new File(System.getProperty("java.io.tmpdir"), "DataCruncher/src"); sourceDir.mkdirs(); String classNamePack = name.replace('.', File.separatorChar); String srcFilePath = sourceDir + "" + File.separatorChar + classNamePack + ".java"; File sourceFile = new File(srcFilePath); if (sourceFile.exists()) { sourceFile.delete(); } FileUtils.writeStringToFile(new File(srcFilePath), code); DynamicClassLoader dynacode = DynamicClassLoader.getInstance(); dynacode.addSourceDir(sourceDir); EventTrigger eventTrigger = (EventTrigger) dynacode.newProxyInstance(EventTrigger.class, name); boolean isValid = false; if (eventTrigger != null) { Class clazz = dynacode.getLoadedClass(name); if (clazz != null) { Class[] interfaces = clazz.getInterfaces(); if (ArrayUtils.isNotEmpty(interfaces)) { for (Class clz : interfaces) { if (clz.getName() .equalsIgnoreCase("com.seer.datacruncher.eventtrigger.EventTrigger")) { isValid = true; } } } else if (clazz.getSuperclass() != null && clazz.getSuperclass().getName() .equalsIgnoreCase("com.seer.datacruncher.eventtrigger.EventTriggerImpl")) { isValid = true; } } } if (isValid) { result = "Success"; } else { result = I18n.getMessage("error.trigger.wrongimpl");//"Failed. Reason: Custom code should implement com.seer.datacruncher.eventtrigger.EventTrigger Interface"; } } catch (Exception e) { result = "Failed. Reason:" + e.getMessage(); } } out.write(mapper.writeValueAsBytes(result)); out.flush(); out.close(); return null; }
From source file:com.microsoft.office.core.AbstractPrimitiveTest.java
protected String getFilename(final String entity, final String propertyName) { return getVersion().name().toLowerCase() + File.separatorChar + entity.replace('(', '_').replace(")", "") + "_" + propertyName.replaceAll("/", "_") + "." + getSuffix(getFormat()); }
From source file:info.magnolia.content2bean.impl.DescriptorFileBasedTypeMapping.java
protected void processFile(String fileName) { Properties props = new Properties(); InputStream stream = null;//from w w w . j av a 2 s .c o m try { stream = ClasspathResourcesUtil.getStream(fileName); props.load(stream); } catch (IOException e) { log.error("can't read collection to bean information " + fileName, e); } IOUtils.closeQuietly(stream); String className = StringUtils.replaceChars(fileName, File.separatorChar, '.'); className = StringUtils.removeStart(className, "."); className = StringUtils.removeEnd(className, ".content2bean"); try { Class<?> typeClass = Classes.getClassFactory().forName(className); TypeDescriptor typeDescriptor = processProperties(typeClass, props); addTypeDescriptor(typeClass, typeDescriptor); } catch (Exception e) { log.error("can't instantiate type descriptor for " + className, e); } }