List of usage examples for java.io File separator
String separator
To view the source code for java.io File separator.
Click Source Link
From source file:com.gagein.crawler.Extractor.java
public static void main(String[] args) { String website = "http://www.gagein.com"; String tempName = "temp"; // ???/*from w w w . j a v a 2s .c o m*/ String dirPath = System.getProperty("user.dir") + File.separator + tempName + File.separator + website.substring(7).split("\\.")[1];// remove http://; Extractor ex = new Extractor(); ex.getFilesPath(dirPath); System.out.println(ex.pathSet); ArticleStripper as = new ArticleStripper(); as.setExtractAuthor(false); as.setExtractContent(true); as.setExtractDate(false); as.setExtractImg(false); as.setKeepContentLink(false); for (String url : ex.pathSet) { System.out.println(url); File file = new File(url); try { String page = FileUtils.readFileToString(file); System.out.println("Contents of file: " + page); logger.debug("==============?" + url + "?"); Article article = as.retrieveArticle(null, null, page, null); System.out.println("##################" + article.getContent()); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.adobe.aem.demomachine.Checksums.java
public static void main(String[] args) { String rootFolder = null;//from www . ja v a 2 s.co m // Command line options for this tool Options options = new Options(); options.addOption("f", true, "Demo Machine root folder"); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("f")) { rootFolder = cmd.getOptionValue("f"); } } catch (Exception e) { System.exit(-1); } Properties md5properties = new Properties(); List<String[]> listPaths = Arrays.asList(AemDemoConstants.demoPaths); for (String[] path : listPaths) { if (path.length == 5) { logger.debug(path[1]); File pathFolder = new File(rootFolder + (path[1].length() > 0 ? (File.separator + path[1]) : "")); if (pathFolder.exists()) { String md5 = AemDemoUtils.calcMD5HashForDir(pathFolder, Boolean.parseBoolean(path[3]), false); logger.debug("MD5 is: " + md5); md5properties.setProperty("demo.path." + path[0], path[1]); md5properties.setProperty("demo.md5." + path[0], md5); } else { logger.error("Folder cannot be found"); } } } File md5 = new File(rootFolder + File.separator + "conf" + File.separator + "checksums.properties"); try { @SuppressWarnings("serial") Properties tmpProperties = new Properties() { @Override public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; tmpProperties.putAll(md5properties); tmpProperties.store(new FileOutputStream(md5), null); } catch (Exception e) { logger.error(e.getMessage()); } System.out.println("MD5 checkums generated"); }
From source file:com.ikanow.aleph2.remote.es_tests.SimpleReadableCrudTest.java
public static void main(final String args[]) throws Exception { if (args.length < 1) { System.out.println("CLI: <host>"); System.exit(-1);//from w ww . j a va 2 s . com } final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator; Config config = ConfigFactory .parseReader(new InputStreamReader( SimpleReadableCrudTest.class.getResourceAsStream("/test_es_remote.properties"))) .withValue("globals.local_root_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.local_cached_jar_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.distributed_root_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.local_yarn_config_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("MongoDbManagementDbService.mongodb_connection", ConfigValueFactory.fromAnyRef(args[0] + ":27017")) .withValue("ElasticsearchCrudService.elasticsearch_connection", ConfigValueFactory.fromAnyRef(args[0] + ":9300")); final SimpleReadableCrudTest app = new SimpleReadableCrudTest(); final Injector app_injector = ModuleUtils.createTestInjector(Arrays.asList(), Optional.of(config)); app_injector.injectMembers(app); app.runTest(); System.exit(0); }
From source file:contractEditor.contractHOST2.java
public static void main(String[] args) { JSONObject obj = new JSONObject(); obj.put("name", "HOST2"); obj.put("context", "VM-deployment"); //obj.put("Context", new Integer); HashMap serviceDescription = new HashMap(); serviceDescription.put("location", "UK"); serviceDescription.put("certificate", "false"); serviceDescription.put("volume", "200_GB"); serviceDescription.put("price", "5_euro"); obj.put("serviceDescription", serviceDescription); HashMap gauranteeTerm = new HashMap(); gauranteeTerm.put("availability", "more_99_percentage"); obj.put("gauranteeTerm", gauranteeTerm); //Constraint1 HashMap host_rule1 = new HashMap(); HashMap VM_rule1 = new HashMap(); host_rule1.put("ID", "HOST2"); VM_rule1.put("data", "private"); ArrayList rule1 = new ArrayList(); rule1.add("prohibition"); rule1.add(host_rule1);/*from w w w . j a va 2s .c o m*/ rule1.add(VM_rule1); ArrayList policyInConstraint1 = new ArrayList(); policyInConstraint1.add(rule1); ArrayList creationConstraint1 = new ArrayList(); creationConstraint1.add("other"); creationConstraint1.add("true"); creationConstraint1.add("true"); creationConstraint1.add(policyInConstraint1); ArrayList totalConstraint = new ArrayList(); totalConstraint.add(creationConstraint1); obj.put("creationConstraint", totalConstraint); try { FileWriter file = new FileWriter("confSP" + File.separator + "Host2.json"); file.write(obj.toJSONString()); file.flush(); file.close(); } catch (IOException e) { e.printStackTrace(); } System.out.print(obj); /* JSONParser parser = new JSONParser(); try { Object obj2 = parser.parse(new FileReader("confSP\\confHost1.json")); JSONObject jsonObject = (JSONObject) obj2; HashMap serviceDescription2=(HashMap) jsonObject.get("serviceDescription"); method.printHashMap(serviceDescription2); HashMap gauranteeTerm2=(HashMap) jsonObject.get("gauranteeTerm"); method.printHashMap(gauranteeTerm2); ArrayList creationConstraint=(ArrayList) jsonObject.get("creationConstraint"); method.printArrayList(creationConstraint); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } */ }
From source file:contractEditor.contractHOST1.java
public static void main(String[] args) { JSONObject obj = new JSONObject(); obj.put("name", "HOST1"); obj.put("context", "VM-deployment"); //obj.put("Context", new Integer); HashMap serviceDescription = new HashMap(); serviceDescription.put("location", "France"); serviceDescription.put("certificate", "true"); serviceDescription.put("volume", "100_GB"); serviceDescription.put("price", "6_euro"); obj.put("serviceDescription", serviceDescription); HashMap gauranteeTerm = new HashMap(); gauranteeTerm.put("availability", "more_98_percentage"); obj.put("gauranteeTerm", gauranteeTerm); //Constraint1 HashMap host_rule1 = new HashMap(); HashMap VM_rule1 = new HashMap(); host_rule1.put("ID", "HOST1"); VM_rule1.put("purpose", "test"); ArrayList rule1 = new ArrayList(); rule1.add("prohibition"); rule1.add(host_rule1);// w w w .j a va 2 s . c o m rule1.add(VM_rule1); ArrayList policyInConstraint1 = new ArrayList(); policyInConstraint1.add(rule1); ArrayList creationConstraint1 = new ArrayList(); creationConstraint1.add("other"); creationConstraint1.add("true"); creationConstraint1.add("true"); creationConstraint1.add(policyInConstraint1); ArrayList totalConstraint = new ArrayList(); totalConstraint.add(creationConstraint1); obj.put("creationConstraint", totalConstraint); try { FileWriter file = new FileWriter("confSP" + File.separator + "Host1.json"); file.write(obj.toJSONString()); file.flush(); file.close(); } catch (IOException e) { e.printStackTrace(); } System.out.print(obj); /* JSONParser parser = new JSONParser(); try { Object obj2 = parser.parse(new FileReader("confSP\\confHost1.json")); JSONObject jsonObject = (JSONObject) obj2; HashMap serviceDescription2=(HashMap) jsonObject.get("serviceDescription"); method.printHashMap(serviceDescription2); HashMap gauranteeTerm2=(HashMap) jsonObject.get("gauranteeTerm"); method.printHashMap(gauranteeTerm2); ArrayList creationConstraint=(ArrayList) jsonObject.get("creationConstraint"); method.printArrayList(creationConstraint); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } */ }
From source file:contractEditor.contractHOST3.java
public static void main(String[] args) { JSONObject obj = new JSONObject(); obj.put("name", "HOST3"); obj.put("context", "VM-deployment"); //obj.put("Context", new Integer); HashMap serviceDescription = new HashMap(); serviceDescription.put("location", "China"); serviceDescription.put("certificate", "false"); serviceDescription.put("volume", "70_GB"); serviceDescription.put("price", "4_euro"); obj.put("serviceDescription", serviceDescription); HashMap gauranteeTerm = new HashMap(); gauranteeTerm.put("availability", "more_97_percentage"); obj.put("gauranteeTerm", gauranteeTerm); //Constraint1 HashMap host_rule1 = new HashMap(); HashMap VM_rule1 = new HashMap(); host_rule1.put("ID", "HOST3"); VM_rule1.put("application", "internal"); ArrayList rule1 = new ArrayList(); rule1.add("prohibition"); rule1.add(host_rule1);//from w w w . ja v a 2s .co m rule1.add(VM_rule1); ArrayList policyInConstraint1 = new ArrayList(); policyInConstraint1.add(rule1); ArrayList creationConstraint1 = new ArrayList(); creationConstraint1.add("other"); creationConstraint1.add("true"); creationConstraint1.add("true"); creationConstraint1.add(policyInConstraint1); ArrayList totalConstraint = new ArrayList(); totalConstraint.add(creationConstraint1); obj.put("creationConstraint", totalConstraint); try { FileWriter file = new FileWriter("confSP" + File.separator + "Host3.json"); file.write(obj.toJSONString()); file.flush(); file.close(); } catch (IOException e) { e.printStackTrace(); } System.out.print(obj); /* JSONParser parser = new JSONParser(); try { Object obj2 = parser.parse(new FileReader("confSP\\confHost1.json")); JSONObject jsonObject = (JSONObject) obj2; HashMap serviceDescription2=(HashMap) jsonObject.get("serviceDescription"); method.printHashMap(serviceDescription2); HashMap gauranteeTerm2=(HashMap) jsonObject.get("gauranteeTerm"); method.printHashMap(gauranteeTerm2); ArrayList creationConstraint=(ArrayList) jsonObject.get("creationConstraint"); method.printArrayList(creationConstraint); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } */ }
From source file:edu.kit.dama.transfer.client.util.TestDataBuilder.java
/** * The entry point./*from w w w. j a v a 2 s . co m*/ * * @param args Command line args. */ public static void main(String[] args) { try { FileUtils.forceMkdir(new File(targetDir)); byte[] oneMegaByte = buildRandomData((int) FileUtils.ONE_KB); for (int i = 0; i < BASE_FILES; i++) { File f = new File(targetDir + i + ".bin"); LOGGER.debug(" - Writing file {}", f); FileUtils.writeByteArrayToFile(f, oneMegaByte); } for (int j = 0; j < SUB_DIRS; j++) { String subdir = targetDir + "subDir" + j; for (int k = 0; k < SUB_SUB_DIRS; k++) { String subsubdir = subdir + "/subsubdir" + k; oneMegaByte = buildRandomData((int) FileUtils.ONE_KB); for (int i = 0; i < FILES_IN_SUB_SUB_DIRS; i++) { File f = new File(subsubdir + File.separator + i + "-" + j + "-" + k + ".bin"); LOGGER.debug(" - Writing file {}", f); FileUtils.writeByteArrayToFile(f, oneMegaByte); } } } } catch (IOException ioe) { LOGGER.error("Failed to build data", ioe); } }
From source file:com.sxjun.core.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????//from w w w. j a v a 2 s . co m // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.sxjun"; String moduleName = "retrieval"; // ???sys String subModuleName = ""; // ????? String className = "IndexManager"; // ??user String classAuthor = "sxjun"; // ThinkGem String functionName = "?"; // ?? // ??? Boolean isEnable = true; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; String classPath = new DefaultResourceLoader().getResource("").getFile().getPath(); String templatePath = classPath.replace( separator + "WebRoot" + separator + "WEB-INF" + separator + "classes", separator + "src" + separator + "com" + separator + "sxjun" + separator + "retrieval"); String javaPath = classPath.replace(separator + "WebRoot" + separator + "WEB-INF" + separator + "classes", separator + "src" + separator + (StringUtils.lowerCase(packageName)).replace(".", separator)); String viewPath = classPath.replace(separator + "classes", separator + "retrieval"); // ??? Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading(new File(templatePath.substring(0, templatePath.lastIndexOf(separator)) + separator + "generate" + separator + "template")); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("urlPrefix", (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) + "/" : "") + model.get("className")); model.put("viewPrefix", StringUtils.substringAfterLast(model.get("packageName"), ".") + "/" + model.get("urlPrefix")); // ? Entity Template template = cfg.getTemplate("pojo.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "pojo" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info(filePath); // ? Dao /*template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath+separator+model.get("moduleName")+separator+"dao"+separator +StringUtils.lowerCase(subModuleName)+separator+model.get("ClassName")+"Dao.java"; writeFile(content, filePath); logger.info(filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath+separator+model.get("moduleName")+separator+"service"+separator +StringUtils.lowerCase(subModuleName)+separator+model.get("ClassName")+"Service.java"; writeFile(content, filePath); logger.info(filePath);*/ // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "controller" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info(filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + model.get("className") + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info(filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + model.get("className") + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info(filePath); logger.info("????"); }
From source file:edu.gslis.ts.RunQuery.java
public static void main(String[] args) { try {/*from w ww .j a va2 s . co m*/ // Get the commandline options Options options = createOptions(); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); String inputPath = cmd.getOptionValue("input"); String eventsPath = cmd.getOptionValue("events"); String stopPath = cmd.getOptionValue("stop"); int queryId = Integer.valueOf(cmd.getOptionValue("query")); List<String> ids = FileUtils.readLines(new File(inputPath + File.separator + "ids.txt")); Stopper stopper = new Stopper(stopPath); Map<Integer, FeatureVector> queries = readEvents(eventsPath, stopper); FeatureVector query = queries.get(queryId); Pairtree ptree = new Pairtree(); Bag<String> words = new HashBag<String>(); for (String streamId : ids) { String ppath = ptree.mapToPPath(streamId.replace("-", "")); String inpath = inputPath + File.separator + ppath + File.separator + streamId + ".xz"; // System.out.println(inpath); File infile = new File(inpath); InputStream in = new XZInputStream(new FileInputStream(infile)); TTransport inTransport = new TIOStreamTransport(new BufferedInputStream(in)); TBinaryProtocol inProtocol = new TBinaryProtocol(inTransport); inTransport.open(); final StreamItem item = new StreamItem(); while (true) { try { item.read(inProtocol); // System.out.println("Read " + item.stream_id); } catch (TTransportException tte) { // END_OF_FILE is used to indicate EOF and is not an exception. if (tte.getType() != TTransportException.END_OF_FILE) tte.printStackTrace(); break; } } // Do something with this document... String docText = item.getBody().getClean_visible(); StringTokenizer itr = new StringTokenizer(docText); while (itr.hasMoreTokens()) { words.add(itr.nextToken()); } inTransport.close(); } for (String term : words.uniqueSet()) { System.out.println(term + ":" + words.getCount(term)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.aistor.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????/*from w w w . j a v a 2s. c o m*/ // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.aistor.modules"; String moduleName = "factory"; // ???sys String subModuleName = ""; // ????? String className = "product"; // ??user String classAuthor = "Zaric"; // Zaric String functionName = "?"; // ?? // ??? Boolean isEnable = false; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; String classPath = new DefaultResourceLoader().getResource("").getFile().getPath(); String templatePath = classPath.replace( separator + "webapp" + separator + "WEB-INF" + separator + "classes", separator + "java" + separator + "com" + separator + "aistor" + separator + "modules"); String javaPath = classPath.replace(separator + "webapp" + separator + "WEB-INF" + separator + "classes", separator + "java" + separator + (StringUtils.lowerCase(packageName)).replace(".", separator)); String viewPath = classPath.replace(separator + "classes", separator + "views"); // ??? Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading( new File(templatePath.replace("modules", "generate" + separator + "template"))); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", StringUtils.substringAfterLast(model.get("packageName"), ".") + "/" + model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info(filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info(filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info(filePath); // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info(filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info(filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info(filePath); logger.info("????"); }