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.du.penrose.systems.util.MyServletContextListener.java
public void contextInitialized(ServletContextEvent context) { MyServletContextListener.myServletContext = context.getServletContext(); String realPath = myServletContext.getRealPath("/"); if (!realPath.endsWith("" + File.separatorChar)) { realPath = realPath + File.separatorChar; }//from w ww .j a v a 2 s . c o m System.setProperty("webapp.root", realPath); }
From source file:ShowFileDialog.java
/** * Creates the contents for the window/*from ww w. ja va2s . c o m*/ * * @param shell the parent shell */ public void createContents(final Shell shell) { shell.setLayout(new GridLayout(5, true)); new Label(shell, SWT.NONE).setText("File Name:"); final Text fileName = new Text(shell, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; fileName.setLayoutData(data); Button multi = new Button(shell, SWT.PUSH); multi.setText("Open Multiple..."); multi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // User has selected to open multiple files FileDialog dlg = new FileDialog(shell, SWT.MULTI); dlg.setFilterNames(FILTER_NAMES); dlg.setFilterExtensions(FILTER_EXTS); String fn = dlg.open(); if (fn != null) { // Append all the selected files. Since getFileNames() returns only // the names, and not the path, prepend the path, normalizing // if necessary StringBuffer buf = new StringBuffer(); String[] files = dlg.getFileNames(); for (int i = 0, n = files.length; i < n; i++) { buf.append(dlg.getFilterPath()); if (buf.charAt(buf.length() - 1) != File.separatorChar) { buf.append(File.separatorChar); } buf.append(files[i]); buf.append(" "); } fileName.setText(buf.toString()); } } }); Button open = new Button(shell, SWT.PUSH); open.setText("Open..."); open.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // User has selected to open a single file FileDialog dlg = new FileDialog(shell, SWT.OPEN); dlg.setFilterNames(FILTER_NAMES); dlg.setFilterExtensions(FILTER_EXTS); String fn = dlg.open(); if (fn != null) { fileName.setText(fn); } } }); Button save = new Button(shell, SWT.PUSH); save.setText("Save..."); save.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // User has selected to save a file FileDialog dlg = new FileDialog(shell, SWT.SAVE); dlg.setFilterNames(FILTER_NAMES); dlg.setFilterExtensions(FILTER_EXTS); String fn = dlg.open(); if (fn != null) { fileName.setText(fn); } } }); }
From source file:org.jvnet.hudson.mojo.MetaBuildMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { // TODO:/* ww w . ja v a2 s . c o m*/ // TODO: 1) Parse the metabuild.xml MetaBuildParser parser = new MetaBuildParser(metaBuildInputFile); metaBuild = parser.parse(); // TODO: 2) Generate job config.xml-s // TODO: ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( "classpath:/META-INF/spring/core-context.xml"); JobConfigGenerator generator = (JobConfigGenerator) appContext.getBean("jobConfigGenerator"); for (JobConfig jobConfig : metaBuild.getJobConfigs()) { getLog().info(jobConfig.toString()); getLog().info(" + Generating config file for project '" + jobConfig.getProjectName() + "':"); getLog().info(" - Subversion URL: " + jobConfig.getScmURL()); getLog().info(" - Maven goals: " + jobConfig.getMavenGoals()); getLog().info(""); File dir = new File(outputDirectory + File.separatorChar + jobConfig.getModuleName()); if (!dir.exists()) //noinspection ResultOfMethodCallIgnored dir.mkdirs(); // if (jobConfig.allowsGoalOverriding() && metaBuild.getGoals().get) // jobConfig.set generator.setJobConfig(jobConfig); generator.setOutputDirectory(dir.getAbsolutePath()); generator.generate(); } }
From source file:edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsBlacklisted.java
/** * Runs through .sparql files in the BLACKLIST_SPARQL_DIR. * /*from w ww. j av a 2 s . c o m*/ * The first that returns one or more rows will be cause the user to be * blacklisted. * * The first variable from the first solution set will be returned. */ private static String checkForBlacklisted(Individual ind, ServletContext context) { String realPath = context.getRealPath(BLACKLIST_SPARQL_DIR); File blacklistDir = new File(realPath); if (!blacklistDir.isDirectory() || !blacklistDir.canRead()) { log.debug("cannot read blacklist directory " + realPath); return NOT_BLACKLISTED; } log.debug("checking directlry " + realPath + " for blacklisting sparql query files"); File[] files = blacklistDir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".sparql"); } }); String reasonForBlacklist = NOT_BLACKLISTED; for (File file : files) { try { reasonForBlacklist = runSparqlFileForBlacklist(file, ind, context); if (reasonForBlacklist != NOT_BLACKLISTED) break; } catch (RuntimeException ex) { log.error("Could not run blacklist check query for file " + file.getAbsolutePath() + File.separatorChar + file.getName(), ex); } } return reasonForBlacklist; }
From source file:com.weibo.datasys.crawler.impl.strategy.rule.save.PageToFileSaveRule.java
@Override public Null apply(ParseInfo parseInfo) { CrawlInfo crawlInfo = parseInfo.getThisCrawlInfo(); Task task = crawlInfo.getValidTask(); if (task == null) { return null; }/*from w w w.ja v a2s .c o m*/ PageData pageData = parseInfo.getPageData(); if (pageData != null) { try { String id = crawlInfo.getSeedData().getExtendField("id"); if (StringUtils.isEmptyString(id)) { id = pageData.getId(); } String path = IOUtil.md5ToPath(id, subDirCount, subDirLength); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String today = sdf.format(new Date()); String pageDirString = baseDir.getPath() + File.separatorChar + today + File.separatorChar + path; File pageDir = new File(pageDirString); pageDir.mkdirs(); String pagePath = pageDir.getPath() + File.separatorChar + id + ".p"; OutputStream out = new BufferedOutputStream(new FileOutputStream(pagePath)); out.write(pageData.getHtml()); out.close(); // logger.info("[SavePageToFile] - url={}", pageData.getUrl()); } catch (Exception e) { logger.error("[PageToFileSaveRuleError] - ", e); } countSaveResult("Page", 1); } return null; }
From source file:be.fgov.kszbcss.rhq.websphere.WebSpherePluginLifecycleListener.java
public void initialize(PluginContext context) throws Exception { // We explicitly manage the lifecycle of the ORB so that we can configure // it without relying on system properties and also cleanly shut it down. log.info("Starting ORB"); // The ORB initialization may change the name of the current thread // (apparently this occurs only for the "main" thread). We don't want that. String threadName = Thread.currentThread().getName(); try {/* w w w . ja v a 2s .c o m*/ Properties orbProps = new Properties(); orbProps.setProperty("com.ibm.CORBA.ConfigURL", WebSpherePluginLifecycleListener.class.getResource("sas.client.props").toExternalForm()); // This prevents the ORB from creating orbtrc files orbProps.setProperty("com.ibm.CORBA.Debug.Output", File.separatorChar == '/' ? "/dev/null" : "NUL"); // Set a reasonable connection timeout. This is important when starting // the RHQ agent while some servers are down (and don't reply to SYN packets). orbProps.setProperty("com.ibm.CORBA.ConnectTimeout", "5"); orb = GlobalORBFactory.init(new String[0], orbProps); } finally { Thread.currentThread().setName(threadName); } TrustStoreManager.init(context); ConfigQueryServiceFactory.init(context); // TODO: we should specify com.ibm.ssl.customTrustManagers and set com.ibm.ssl.skipDefaultTrustManagerWhenCustomDefined=true // to use our own trust manager so that we can reload the trust store without restarting the agent; // the TrustManagerExtendedInfo interface may also be interesting Security.addProvider(new CustomProvider()); sslConfig = new SSLConfig(); sslConfig.setProperty("com.ibm.ssl.dynamicSelectionInfo", "*,*,*"); sslConfig.setProperty("com.ibm.ssl.trustStore", "dummy"); sslConfig.setProperty("com.ibm.ssl.trustStorePassword", "dummy"); sslConfig.setProperty("com.ibm.ssl.trustManager", "Delegating|" + CustomProvider.NAME); configManager = SSLConfigManager.getInstance(); configManager.addSSLConfigToMap(SSL_CONFIG_ALIAS, sslConfig); }
From source file:de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager.java
public String getTargetPath() { String path = user.getFileBase() + Config.FILE_FILES_BASE + File.separatorChar; new File(path).mkdirs(); return path; }
From source file:eu.smartfp7.foursquare.utils.Settings.java
/** Returns the folder where all the data will be downloaded. */ public String getFolder() { String path = this.settings_json.get("crawl_folder").getAsString(); if (path.charAt(path.length() - 1) != File.separatorChar) path += File.separator;/*ww w. jav a 2 s . c o m*/ return path; }
From source file:com.xylocore.copybook.generator.CopybookClassGenerator.java
/** * FILLIN//from w w w .j a va 2 s . c om */ public void generate() { validateEnvironment(); try { processCopybook(); Metadata myMetadata = environment.getMetadata(); String myPackageName = ClassUtils.getPackageName(myMetadata.getClassName()); String myClassName = ClassUtils.getShortClassName(myMetadata.getClassName()); File myGenerationRootDirectory = new File(environment.getGenerationRootDirectory()); File myOutputDirectory = StringUtils.isNotEmpty(myPackageName) ? new File(myGenerationRootDirectory, myPackageName.replace('.', File.separatorChar)) : myGenerationRootDirectory; myOutputDirectory.mkdirs(); File myOutputFile = new File(myOutputDirectory, myClassName + ".java"); try (FileWriter myWriter = new FileWriter(myOutputFile)) { selectElementsOfInterest(); copybookClassEmitter.generate(environment, copybook, elementsOfInterest, myWriter); } catch (IOException myIOException) { // TODO: throw an appropriate exception } } catch (Exception myException) { // TODO: throw an appropriate exception throw new RuntimeException(myException.getMessage(), myException); } }
From source file:gov.nih.nci.sdk.example.generator.util.GeneratorUtil.java
public static String getPojoPath(ScriptContext _scriptContext) { String jaxbPojoPath = getGeneratedPath(_scriptContext) + File.separator + EcoreUtil.determinePackageName(_scriptContext.getFocusDomain()).replace('.', File.separatorChar) + File.separator + Generator.POJO_PACKAGE_NAME; return jaxbPojoPath; }