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:gov.nih.nci.sdk.example.generator.util.GeneratorUtil.java
public static String getServicePath(ScriptContext _scriptContext) { return getGeneratedPath(_scriptContext) + File.separator + EcoreUtil.determinePackageName(_scriptContext.getFocusDomain()).replace('.', File.separatorChar) + File.separator + Generator.SERVICE_PACKAGE_NAME; }
From source file:org.rivetlogic.utils.IntegrationUtils.java
public static String decodePath(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 = pStr.substring(0, prefix.length() + 1) + ISO9075.decode(pStr.substring(prefix.length() + 1)); break; }/*w w w .j av a 2s .c o m*/ } pathBuilder.append(File.separatorChar); pathBuilder.append(pStr); } } } return pathBuilder.toString(); }
From source file:com.netspective.commons.io.UriAddressableInheritableFileResource.java
public UriAddressableFile findUriAddressableFile(final String name) throws IOException { final boolean logging = log.isDebugEnabled(); UriAddressableFile result = null;//from ww w.j a v a 2s.co m if (cacheLocations) { result = (UriAddressableFile) cache.get(name); if (result != null) { if (logging) log.debug("UriAddressableInheritableFileResource cache hit for " + result); return result; } } result = super.findUriAddressableFile(name); if (result != null) { cache.put(name, result); return result; } String[] pathItems = TextUtils.getInstance() .split(SEP_IS_SLASH ? name : name.replace(File.separatorChar, '/'), "/", false); String justName = pathItems[pathItems.length - 1]; // get just the name then start looking "up" the parents until we get to the base directory // e.g. if pathItems is /a/b/c/d.gif then we start searching at /a/b/d.gif, then /a/d.gif, then /d.gif, etc int pathItemToSearch = pathItems.length - 2; while (pathItemToSearch >= 0) { StringBuffer buildPath = new StringBuffer(); for (int i = 0; i < pathItemToSearch; i++) { buildPath.append(pathItems[i]); buildPath.append('/'); } buildPath.append(justName); result = super.findUriAddressableFile(buildPath.toString()); if (result != null) { // even if we inherited the file we look for it in the cache as the original name if (cacheLocations) cache.put(name, result); return result; } pathItemToSearch--; } return null; }
From source file:com.microsoft.office.core.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);/*ww w . j a v a2s . c om*/ 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 = ODataObjectFactory.newComplexProperty(written.getName(), typedValue); } assertEquals(property, comparable); return property; }
From source file:it.eng.spagobi.engines.exporters.KpiExporter.java
public File getKpiReportPDF(List<KpiResourceBlock> kpiBlocks, BIObject obj, String userId) throws Exception { logger.debug("IN"); //Build report template String docName = (obj != null) ? obj.getName() : ""; BasicTemplateBuilder basic = new BasicTemplateBuilder(docName); String template2 = ""; List templates = basic.buildTemplate(kpiBlocks); boolean first = true; //String template2=basic.buildTemplate(kpiBlocks); //System.out.println(template2); String outputType = "PDF"; HashedMap parameters = new HashedMap(); parameters.put("PARAM_OUTPUT_FORMAT", outputType); //parameters.put("SBI_HTTP_SESSION", session); ??? JREmptyDataSource conn = new JREmptyDataSource(1); // identity string for object execution UUIDGenerator uuidGen = UUIDGenerator.getInstance(); UUID uuid_local = uuidGen.generateTimeBasedUUID(); String executionId = uuid_local.toString(); executionId = executionId.replaceAll("-", ""); //Creta etemp file String dirS = System.getProperty("java.io.tmpdir"); File dir = new File(dirS); dir.mkdirs();//from w ww .j a v a2 s .c o m List filesToDelete = new ArrayList(); logger.debug("Create Temp File"); String fileName = "report" + executionId; File tmpFile = File.createTempFile(fileName, "." + outputType, dir); OutputStream out = new FileOutputStream(tmpFile); try { if (templates != null && !templates.isEmpty()) { int subreports = 0; Iterator it = templates.iterator(); while (it.hasNext()) { String template = (String) it.next(); if (first) template2 = template; else { File f = new File(dirS + File.separatorChar + "Detail" + subreports + ".jasper"); logger.debug("Compiling subtemplate file: " + f); filesToDelete.add(f); File file = new File(dirS + File.separatorChar + "Detail" + subreports + ".jrxml"); if (file.exists()) { boolean deleted = file.delete(); file = new File(dirS + File.separatorChar + "Detail" + subreports + ".jrxml"); } FileOutputStream stream = new FileOutputStream(file); stream.write(template.getBytes()); stream.flush(); stream.close(); filesToDelete.add(file); JasperCompileManager.compileReportToFile( dirS + File.separatorChar + "Detail" + subreports + ".jrxml", dirS + File.separatorChar + "Detail" + subreports + ".jasper"); subreports++; } first = false; } } File f = new File(dirS + File.separatorChar + "Master.jasper"); logger.debug("Compiling subtemplate file: " + f); filesToDelete.add(f); File file = new File(dirS + File.separatorChar + "Master.jrxml"); if (file.exists()) { boolean deleted = file.delete(); file = new File(dirS + File.separatorChar + "Master.jrxml"); } FileOutputStream stream = new FileOutputStream(file); stream.write(template2.getBytes()); stream.flush(); stream.close(); filesToDelete.add(file); StringBufferInputStream sbis = new StringBufferInputStream(template2); JasperCompileManager.compileReportToFile(dirS + File.separatorChar + "Master.jrxml", dirS + File.separatorChar + "Master.jasper"); logger.debug("Filling report ..."); Context ctx = new InitialContext(); Session aSession = HibernateUtil.currentSession(); JasperPrint jasperPrint = null; try { Transaction tx = aSession.beginTransaction(); //Connection jdbcConnection = aSession.connection(); Connection jdbcConnection = HibernateUtil.getConnection(aSession); jasperPrint = JasperFillManager.fillReport(dirS + File.separatorChar + "Master.jasper", parameters, jdbcConnection); logger.debug("Report filled succesfully"); } finally { if (aSession != null) { if (aSession.isOpen()) aSession.close(); } } logger.debug("Exporting report: Output format is [" + outputType + "]"); JRExporter exporter = null; //JRExporter exporter = ExporterFactory.getExporter(outputType); // Set the PDF exporter exporter = (JRExporter) Class.forName("net.sf.jasperreports.engine.export.JRPdfExporter").newInstance(); if (exporter == null) exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out); exporter.exportReport(); logger.debug("Report exported succesfully"); //in = new BufferedInputStream(new FileInputStream(tmpFile)); logger.debug("OUT"); return tmpFile; } catch (Throwable e) { logger.error("An exception has occured", e); throw new Exception(e); } finally { out.flush(); out.close(); if (filesToDelete != null && !filesToDelete.isEmpty()) { Iterator it = filesToDelete.iterator(); while (it.hasNext()) { File temp = (File) it.next(); temp.delete(); } } //tmpFile.delete(); } }
From source file:org.eclipse.virgo.ide.facet.core.FacetUtils.java
public static Par getParDefinition(IProject project) { // Create a resource set to hold the resources. ResourceSet resourceSet = new ResourceSetImpl(); // Register the package to ensure it is available during loading. resourceSet.getPackageRegistry().put(ParPackage.eNS_URI, ParPackage.eINSTANCE); File parFile = new File(new File(project.getLocation().toString() + File.separatorChar + ".settings"), "org.eclipse.virgo.ide.runtime.core.par.xml"); if (parFile.exists()) { URI fileUri = URI.createFileURI(parFile.toString()); Resource resource = resourceSet.getResource(fileUri, true); return (Par) resource.getContents().iterator().next(); }//w w w . j av a 2s. co m return null; }
From source file:com.flexive.core.storage.binary.FxBinaryUtils.java
/** * Create a new binary transit file for the given division and handle * * @param divisionId division/*from ww w . j a v a2 s . c om*/ * @param handle binary handle * @param ttl time to live (will be part of the filename) * @return transit file * @throws IOException on errors */ public static File createTransitFile(int divisionId, String handle, long ttl) throws IOException { File baseDir = new File(getTransitDirectory() + File.separatorChar + String.valueOf(divisionId)); if (!baseDir.exists()) if (!baseDir.mkdirs()) throw new IOException("Failed to create directory " + baseDir.getAbsolutePath()); File result = new File( baseDir.getAbsolutePath() + File.separatorChar + handle + "__" + String.valueOf(ttl) + TRANSIT_EXT); if (!result.createNewFile()) throw new IOException("Failed to create file " + result.getAbsolutePath()); return result; }
From source file:com.jaxio.celerio.template.pack.LocalResourcePackFile.java
private String getAbsoluteTemplate(String template) { return normalize(packAbsolutePath + File.separatorChar + template); }
From source file:com.silverpeas.gallery.servlets.GalleryDragAndDrop.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { SilverTrace.info("gallery", "GalleryDragAndDrop.doPost", "root.MSG_GEN_ENTER_METHOD"); String userId = null;/*from ww w .java 2 s .c o m*/ HttpRequest request = HttpRequest.decorate(req); try { request.setCharacterEncoding("UTF-8"); String componentId = request.getParameter("ComponentId"); String albumId = request.getParameter("AlbumId"); userId = request.getParameter("UserId"); SilverTrace.info("gallery", "GalleryDragAndDrop.doPost", "root.MSG_GEN_PARAM_VALUE", "componentId = " + componentId + " albumId = " + albumId + " userId = " + userId); String savePath = FileRepositoryManager.getTemporaryPath() + File.separatorChar + userId + System.currentTimeMillis() + File.separatorChar; List<FileItem> items = request.getFileItems(); String parentPath = getParameterValue(items, "userfile_parent"); SilverTrace.info("gallery", "GalleryDragAndDrop.doPost.doPost", "root.MSG_GEN_PARAM_VALUE", "parentPath = " + parentPath); SilverTrace.info("gallery", "GalleryDragAndDrop.doPost.doPost", "root.MSG_GEN_PARAM_VALUE", "debut de la boucle"); for (FileItem item : items) { if (!item.isFormField()) { String fileName = FileUploadUtil.getFileName(item); SilverTrace.info("gallery", "GalleryDragAndDrop.doPost.doPost", "root.MSG_GEN_PARAM_VALUE", "item = " + item.getFieldName() + " - " + fileName); if (fileName != null) { SilverTrace.info("gallery", "GalleryDragAndDrop.doPost.doPost", "root.MSG_GEN_PARAM_VALUE", "fileName = " + fileName); // modifier le nom avant de l'crire File f = new File(savePath + File.separatorChar + fileName); File parent = f.getParentFile(); if (!parent.exists()) { parent.mkdirs(); } item.write(f); // Cas du zip if (FileUtil.isArchive(fileName)) { ZipManager.extract(f, parent); } } } } importRepository(new File(savePath), userId, componentId, albumId); FileFolderManager.deleteFolder(savePath); } catch (Exception e) { SilverTrace.debug("gallery", "GalleryDragAndDrop.doPost.doPost", "root.MSG_GEN_PARAM_VALUE", e); final StringBuilder sb = new StringBuilder("ERROR"); final String errorMessage = SilverpeasTransverseWebErrorUtil.performAppletAlertExceptionMessage(e, UserDetail.getById(userId).getUserPreferences().getLanguage()); if (isDefined(errorMessage)) { sb.append(": "); sb.append(errorMessage); } res.getOutputStream().println(sb.toString()); } res.getOutputStream().println("SUCCESS"); }
From source file:org.apache.sling.i18n.it.ResourceBundleProviderIT.java
@Configuration public Option[] config() { final String buildDir = System.getProperty(SYS_PROP_BUILD_DIR, DEFAULT_BUILD_DIR); final String bundleFileName = System.getProperty(BUNDLE_JAR_SYS_PROP); final File bundleFile = new File(bundleFileName); if (!bundleFile.canRead()) { throw new IllegalArgumentException("Cannot read from bundle file " + bundleFileName + " specified in the " + BUNDLE_JAR_SYS_PROP + " system property"); }//from w w w .j a va 2s . c om String localRepo = System.getProperty("maven.repo.local", ""); final String jackrabbitVersion = "2.13.1"; final String oakVersion = "1.5.7"; final String slingHome = new File(buildDir + File.separatorChar + "sling_" + System.currentTimeMillis()) .getAbsolutePath(); return options(frameworkProperty("sling.home").value(slingHome), frameworkProperty("repository.home").value(slingHome + File.separatorChar + "repository"), when(localRepo.length() > 0) .useOptions(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)), when(System.getProperty(PORT_CONFIG) != null) .useOptions(systemProperty(PORT_CONFIG).value(System.getProperty(PORT_CONFIG))), systemProperty("pax.exam.osgi.unresolved.fail").value("true"), ConfigurationAdminOptions.newConfiguration("org.apache.felix.jaas.ConfigurationSpi").create(true) .put("jaas.defaultRealmName", "jackrabbit.oak") .put("jaas.configProviderName", "FelixJaasProvider").asOption(), ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") .create(true).put("jaas.controlFlag", "optional") .put("jaas.classname", "org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule") .put("jaas.ranking", 300).asOption(), ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") .create(true).put("jaas.controlFlag", "required") .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl") .asOption(), ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") .create(true).put("jaas.controlFlag", "sufficient") .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule") .put("jaas.ranking", 200).asOption(), ConfigurationAdminOptions .newConfiguration( "org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl") .create(true) .put("org.apache.jackrabbit.oak.authentication.configSpiName", "FelixJaasProvider") .asOption(), ConfigurationAdminOptions .newConfiguration("org.apache.jackrabbit.oak.security.user.UserConfigurationImpl") .create(true).put("groupsPath", "/home/groups").put("usersPath", "/home/users") .put("defaultPath", "1").put("importBehavior", "besteffort").asOption(), ConfigurationAdminOptions .newConfiguration("org.apache.jackrabbit.oak.security.user.RandomAuthorizableNodeName") .create(true) .put("enabledActions", new String[] { "org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction" }) .put("userPrivilegeNames", new String[] { "jcr:all" }) .put("groupPrivilegeNames", new String[] { "jcr:read" }).asOption(), ConfigurationAdminOptions.newConfiguration( "org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider") .create(true).put("length", 21).asOption(), ConfigurationAdminOptions .newConfiguration("org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService") .create(true).put("name", "Default NodeStore").asOption(), ConfigurationAdminOptions .newConfiguration( "org.apache.sling.resourceresolver.impl.observation.OsgiObservationBridge") .create(true).put("enabled", true).asOption(), // logging systemProperty("pax.exam.logging").value("none"), mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"), mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"), mavenBundle("org.slf4j", "slf4j-api", "1.7.13"), mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.13"), mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.13"), mavenBundle("commons-io", "commons-io", "2.4"), mavenBundle("commons-fileupload", "commons-fileupload", "1.3.1"), mavenBundle("commons-collections", "commons-collections", "3.2.2"), mavenBundle("commons-codec", "commons-codec", "1.10"), mavenBundle("commons-lang", "commons-lang", "2.6"), mavenBundle("commons-pool", "commons-pool", "1.6"), mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.concurrent", "1.3.4_1"), mavenBundle("org.apache.geronimo.bundles", "commons-httpclient", "3.1_1"), mavenBundle("org.apache.tika", "tika-core", "1.9"), mavenBundle("org.apache.tika", "tika-bundle", "1.9"), // infrastructure mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2"), mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "3.1.6"), mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.4.4"), mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.0.4"), mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.10"), mavenBundle("org.apache.felix", "org.apache.felix.inventory", "1.0.4"), mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.1.2"), // sling mavenBundle("org.apache.sling", "org.apache.sling.settings", "1.3.8"), mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi", "2.3.0"), mavenBundle("org.apache.sling", "org.apache.sling.commons.json", "2.0.16"), mavenBundle("org.apache.sling", "org.apache.sling.commons.mime", "2.1.8"), mavenBundle("org.apache.sling", "org.apache.sling.commons.classloader", "1.3.2"), mavenBundle("org.apache.sling", "org.apache.sling.commons.scheduler", "2.4.14"), mavenBundle("org.apache.sling", "org.apache.sling.commons.threads", "3.2.4"), mavenBundle("org.apache.sling", "org.apache.sling.auth.core", "1.3.12"), mavenBundle("org.apache.sling", "org.apache.sling.discovery.api", "1.0.2"), mavenBundle("org.apache.sling", "org.apache.sling.discovery.commons", "1.0.12"), mavenBundle("org.apache.sling", "org.apache.sling.discovery.standalone", "1.0.2"), mavenBundle("org.apache.sling", "org.apache.sling.api", "2.14.2"), mavenBundle("org.apache.sling", "org.apache.sling.resourceresolver", "1.4.18"), mavenBundle("org.apache.sling", "org.apache.sling.adapter", "2.1.2"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource", "2.8.0"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.classloader", "3.2.2"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.contentloader", "2.1.8"), mavenBundle("org.apache.sling", "org.apache.sling.engine", "2.6.2"), mavenBundle("org.apache.sling", "org.apache.sling.serviceusermapper", "1.2.2"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.jcr-wrapper", "2.0.0"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.api", "2.4.0"), mavenBundle("org.apache.sling", "org.apache.sling.jcr.base", "2.4.0"), mavenBundle("com.google.guava", "guava", "15.0"), mavenBundle("org.apache.jackrabbit", "jackrabbit-api", jackrabbitVersion), mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", jackrabbitVersion), mavenBundle("org.apache.jackrabbit", "jackrabbit-spi", jackrabbitVersion), mavenBundle("org.apache.jackrabbit", "jackrabbit-spi-commons", jackrabbitVersion), mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-rmi", jackrabbitVersion), mavenBundle("org.apache.felix", "org.apache.felix.jaas", "0.0.4"), mavenBundle("org.apache.jackrabbit", "oak-core", oakVersion), mavenBundle("org.apache.jackrabbit", "oak-commons", oakVersion), mavenBundle("org.apache.jackrabbit", "oak-lucene", oakVersion), mavenBundle("org.apache.jackrabbit", "oak-blob", oakVersion), mavenBundle("org.apache.jackrabbit", "oak-jcr", oakVersion), mavenBundle("org.apache.jackrabbit", "oak-segment", oakVersion), mavenBundle("org.apache.sling", "org.apache.sling.jcr.oak.server", "1.1.0"), mavenBundle("org.apache.sling", "org.apache.sling.testing.tools", "1.0.6"), mavenBundle("org.apache.httpcomponents", "httpcore-osgi", "4.1.2"), mavenBundle("org.apache.httpcomponents", "httpclient-osgi", "4.1.2"), junitBundles(), CoreOptions.bundle(bundleFile.toURI().toString())); }