List of usage examples for java.util ArrayList ArrayList
public ArrayList()
From source file:com.xandrev.altafitcalendargenerator.Main.java
public static void main(String[] args) { CalendarPrinter printer = new CalendarPrinter(); XLSExtractor extractor = new XLSExtractor(); if (args != null && args.length > 0) { try {/*from ww w . ja va 2s. co m*/ Options opt = new Options(); opt.addOption("f", true, "Filepath of the XLS file"); opt.addOption("t", true, "Type name of activities"); opt.addOption("m", true, "Month index"); opt.addOption("o", true, "Output filename of the generated ICS"); BasicParser parser = new BasicParser(); CommandLine cliParser = parser.parse(opt, args); if (cliParser.hasOption("f")) { String fileName = cliParser.getOptionValue("f"); LOG.debug("File name to be imported: " + fileName); String activityNames = cliParser.getOptionValue("t"); LOG.debug("Activity type names: " + activityNames); ArrayList<String> nameList = new ArrayList<>(); String[] actNames = activityNames.split(","); if (actNames != null) { nameList.addAll(Arrays.asList(actNames)); } LOG.debug("Sucessfully activities parsed: " + nameList.size()); if (cliParser.hasOption("m")) { String monthIdx = cliParser.getOptionValue("m"); LOG.debug("Month index: " + monthIdx); int month = Integer.parseInt(monthIdx) - 1; if (cliParser.hasOption("o")) { String outputfilePath = cliParser.getOptionValue("o"); LOG.debug("Output file to be generated: " + monthIdx); LOG.debug("Starting to extract the spreadsheet"); HashMap<Integer, ArrayList<TimeTrack>> result = extractor.importExcelSheet(fileName); LOG.debug("Extracted the spreadsheet done"); LOG.debug("Starting the filter of the data"); HashMap<Date, String> cal = printer.getCalendaryByItem(result, nameList, month); LOG.debug("Finished the filter of the data"); LOG.debug("Creating the ics Calendar"); net.fortuna.ical4j.model.Calendar calendar = printer.createICSCalendar(cal); LOG.debug("Finished the ics Calendar"); LOG.debug("Printing the ICS file to: " + outputfilePath); printer.saveCalendar(calendar, outputfilePath); LOG.debug("Finished the ICS file to: " + outputfilePath); } } } } catch (ParseException ex) { LOG.error("Error parsing the argument list: ", ex); } } }
From source file:io.fabric8.vertx.maven.plugin.FileFilterMain.java
public static void main(String[] args) { Commandline commandline = new Commandline(); commandline.setExecutable("java"); commandline.createArg().setValue("io.vertx.core.Launcher"); commandline.createArg().setValue("--redeploy=target/**/*"); System.out.println(commandline);//w w w .ja va2 s . co m File baseDir = new File("/Users/kameshs/git/fabric8io/vertx-maven-plugin/samples/vertx-demo"); List<String> includes = new ArrayList<>(); includes.add("src/**/*.java"); //FileAlterationMonitor monitor = null; try { Set<Path> inclDirs = new HashSet<>(); includes.forEach(s -> { try { if (s.startsWith("**")) { Path rootPath = Paths.get(baseDir.toString()); if (Files.exists(rootPath)) { File[] dirs = rootPath.toFile().listFiles((dir, name) -> dir.isDirectory()); Objects.requireNonNull(dirs); Stream.of(dirs).forEach(f -> inclDirs.add(Paths.get(f.toString()))); } } else if (s.contains("**")) { String root = s.substring(0, s.indexOf("/**")); Path rootPath = Paths.get(baseDir.toString(), root); if (Files.exists(rootPath)) { File[] dirs = rootPath.toFile().listFiles((dir, name) -> dir.isDirectory()); Objects.requireNonNull(dirs); Stream.of(dirs).forEach(f -> inclDirs.add(Paths.get(f.toString()))); } } List<Path> dirs = FileUtils.getFileAndDirectoryNames(baseDir, s, null, true, true, true, true) .stream().map(FileUtils::dirname).map(Paths::get) .filter(p -> Files.exists(p) && Files.isDirectory(p)).collect(Collectors.toList()); inclDirs.addAll(dirs); } catch (Exception e) { e.printStackTrace(); } }); FileAlterationMonitor monitor = fileWatcher(inclDirs); Runnable monitorTask = () -> { try { monitor.start(); } catch (Exception e) { e.printStackTrace(); } }; monitorTask.run(); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.pniehus.odal.App.java
public static void main(String[] args) throws IOException { List<Filter> filters = new ArrayList<Filter>(); filters.add(new RegexFilter()); filters.add(new FileTypeFilter()); filters.add(new KeywordFilter()); filters.add(new BlacklistFilter()); Profile p = parseArgs(args, filters); String fileName = "log-" + new Date().toString().replace(":", "-") + ".txt"; fileName = fileName.replace(" ", "-"); File logPath = new File(p.getLogDirectory() + fileName); if (!logPath.getParentFile().isDirectory() && !logPath.getParentFile().mkdirs()) { logPath = new File(fileName); }//from www.j av a 2s . co m if (logPath.getParentFile().canWrite() || logPath.getParentFile().setWritable(true)) { SimpleLoggingSetup.configureRootLogger(logPath.getAbsolutePath(), p.getLogLevel(), !p.isSilent()); } else { Logger root = Logger.getLogger(""); for (Handler h : root.getHandlers()) { // Removing default console handlers if (h instanceof ConsoleHandler) { root.removeHandler(h); } } ConsolePrintLogHandler cplh = new ConsolePrintLogHandler(); cplh.setFormatter(new ScribblerLogFormat(SimpleLoggingSetup.DEFAULT_DATE_FORMAT)); root.addHandler(cplh); System.out.println("Unable to create log: insufficient permissions!"); } Logger.getLogger("").setLevel(p.getLogLevel()); mainLogger = Logger.getLogger(App.class.getCanonicalName()); untrustedSSLSetup(); mainLogger.info("Successfully intitialized ODAL"); if (!p.isLogging()) mainLogger.setLevel(Level.OFF); if (p.isWindowsConsoleMode() && !p.isLogging()) { Logger root = Logger.getLogger(""); for (Handler h : root.getHandlers()) { if (h instanceof FileHandler) { root.removeHandler(h); // Removes FileHandler to allow console output through logging } } } OdalGui ogui = new OdalGui(p, filters); }
From source file:io.reactiverse.vertx.maven.plugin.FileFilterMain.java
public static void main(String[] args) { Commandline commandline = new Commandline(); commandline.setExecutable("java"); commandline.createArg().setValue("io.vertx.core.Launcher"); commandline.createArg().setValue("--redeploy=target/**/*"); System.out.println(commandline);/*from w w w. j a v a 2 s . c om*/ File baseDir = new File("/Users/kameshs/git/reactiverse/vertx-maven-plugin/samples/vertx-demo"); List<String> includes = new ArrayList<>(); includes.add("src/**/*.java"); //FileAlterationMonitor monitor = null; try { Set<Path> inclDirs = new HashSet<>(); includes.forEach(s -> { try { if (s.startsWith("**")) { Path rootPath = Paths.get(baseDir.toString()); if (Files.exists(rootPath)) { File[] dirs = rootPath.toFile().listFiles((dir, name) -> dir.isDirectory()); Objects.requireNonNull(dirs); Stream.of(dirs).forEach(f -> inclDirs.add(Paths.get(f.toString()))); } } else if (s.contains("**")) { String root = s.substring(0, s.indexOf("/**")); Path rootPath = Paths.get(baseDir.toString(), root); if (Files.exists(rootPath)) { File[] dirs = rootPath.toFile().listFiles((dir, name) -> dir.isDirectory()); Objects.requireNonNull(dirs); Stream.of(dirs).forEach(f -> inclDirs.add(Paths.get(f.toString()))); } } List<Path> dirs = FileUtils.getFileAndDirectoryNames(baseDir, s, null, true, true, true, true) .stream().map(FileUtils::dirname).map(Paths::get) .filter(p -> Files.exists(p) && Files.isDirectory(p)).collect(Collectors.toList()); inclDirs.addAll(dirs); } catch (Exception e) { e.printStackTrace(); } }); FileAlterationMonitor monitor = fileWatcher(inclDirs); Runnable monitorTask = () -> { try { monitor.start(); } catch (Exception e) { e.printStackTrace(); } }; monitorTask.run(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.hcmut.emr.SessionBuilder.java
public static void main(String[] args) throws FileNotFoundException, IOException { try (BufferedReader br = new BufferedReader( new FileReader("/home/sinhlk/myspace/emr/src/main/resources/patern"))) { ObjectMapper jsonMapper = new ObjectMapper(); String line = br.readLine(); Map<String, String> result = new HashMap<String, String>(); List<NameValuePair> list = new ArrayList<>(); while (line != null) { if (line != null && line != "") { list.add(new BasicNameValuePair(line.trim().toLowerCase(), SessionBuilder.buildValue(line))); result.put(line.trim().toLowerCase(), SessionBuilder.buildValue(line)); line = br.readLine();/*from www.j av a 2 s. c o m*/ } } System.out.println(jsonMapper.writeValueAsString(list)); File file = new File("/home/sinhlk/myspace/emr/src/main/resources/session.js"); jsonMapper.writeValue(file, list); } }
From source file:edu.berkeley.path.next.CTMEngine.CTMEngineApp.java
public static void main(String[] args) throws InterruptedException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ctm-engine.xml"); context.start();/*from w w w . ja va2 s . com*/ final Logger logger = LogManager.getLogger(CTMEngineApp.class.getName()); logger.info("trafficMonitorApp initialized "); JmsPublish jmsPublish = context.getBean(JmsPublish.class); // linkManager creates the data to publish representing ccFramework output LinkManager linkManager = context.getBean(LinkManager.class); logger.info("trafficMonitorApp initialized "); //get a list of output links that we will publish over and over java.util.List<LinkDataRaw> links = new ArrayList<LinkDataRaw>(); links = linkManager.getLinkList(); logger.info("trafficMonitorApp links to publish: " + links.size()); //counters int x = 0; int oneHour = 216000; int oneMinute = 3600; while (x < oneMinute) { //use SLF interface which provides for parameterized logging logger.info("CTMEngineApp sendLinkList counter: " + x); jmsPublish.sendLinkList(links); //sleep for a third of a second //Thread.sleep(10); x++; } }
From source file:hk.mcc.utils.applog2es.Main.java
/** * @param args the command line arguments *///from w w w. ja v a2 s . c o m public static void main(String[] args) throws Exception { String pathString = "G:\\tmp\\Archive20160902"; Path path = Paths.get(pathString); try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, "app*.log")) { for (Path entry : stream) { List<AppLog> appLogs = new ArrayList<>(); try (AppLogParser appLogParser = new AppLogParser(Files.newInputStream(entry))) { AppLog nextLog = appLogParser.nextLog(); while (nextLog != null) { // System.out.println(nextLog); nextLog = appLogParser.nextLog(); appLogs.add(nextLog); } post2ES(appLogs); } catch (IOException ex) { Logger.getLogger(AppLogParser.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:isc_415_practica_1.ISC_415_Practica_1.java
/** * @param args the command line arguments *//* w w w .j a va 2 s . com*/ public static void main(String[] args) { String urlString; Scanner input = new Scanner(System.in); Document doc; try { urlString = input.next(); if (urlString.equals("servlet")) { urlString = "http://localhost:8084/ISC_415_Practica1_Servlet/client"; } urlString = urlString.contains("http://") || urlString.contains("https://") ? urlString : "http://" + urlString; doc = Jsoup.connect(urlString).get(); } catch (Exception ex) { System.out.println("El URL ingresado no es valido."); return; } ArrayList<NameValuePair> formInputParams; formInputParams = new ArrayList<>(); String[] plainTextDoc = new TextNode(doc.html(), "").getWholeText().split("\n"); System.out.println(String.format("Nmero de lineas del documento: %d", plainTextDoc.length)); System.out.println(String.format("Nmero de p tags: %d", doc.select("p").size())); System.out.println(String.format("Nmero de img tags: %d", doc.select("img").size())); System.out.println(String.format("Nmero de form tags: %d", doc.select("form").size())); Integer index = 1; ArrayList<NameValuePair> urlParameters = new ArrayList<>(); for (Element e : doc.select("form")) { System.out.println(String.format("Form %d: Nmero de Input tags %d", index, e.select("input").size())); System.out.println(e.select("input")); for (Element formInput : e.select("input")) { if (formInput.attr("id") != null && formInput.attr("id") != "") { urlParameters.add(new BasicNameValuePair(formInput.attr("id"), "PRACTICA1")); } else if (formInput.attr("name") != null && formInput.attr("name") != "") { urlParameters.add(new BasicNameValuePair(formInput.attr("name"), "PRACTICA1")); } } index++; } if (!urlParameters.isEmpty()) { try { CloseableHttpClient httpclient = HttpClients.createDefault(); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(urlParameters, Consts.UTF_8); HttpPost httpPost = new HttpPost(urlString); httpPost.setHeader("User-Agent", USER_AGENT); httpPost.setEntity(entity); HttpResponse response = httpclient.execute(httpPost); System.out.println(response.getStatusLine()); } catch (IOException ex) { Logger.getLogger(ISC_415_Practica_1.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.liferay.nativity.test.TestDriver.java
public static void main(String[] args) { _intitializeLogging();/* w ww. ja v a 2 s . c om*/ List<String> items = new ArrayList<String>(); items.add("ONE"); NativityMessage message = new NativityMessage("BLAH", items); try { _logger.debug(_objectMapper.writeValueAsString(message)); } catch (JsonProcessingException jpe) { _logger.error(jpe.getMessage(), jpe); } _logger.debug("main"); NativityControl nativityControl = NativityControlUtil.getNativityControl(); FileIconControl fileIconControl = FileIconControlUtil.getFileIconControl(nativityControl, new TestFileIconControlCallback()); ContextMenuControlUtil.getContextMenuControl(nativityControl, new TestContextMenuControlCallback()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); nativityControl.connect(); String read = ""; boolean stop = false; try { while (!stop) { _list = !_list; _logger.debug("Loop start..."); _logger.debug("_enableFileIcons"); _enableFileIcons(fileIconControl); _logger.debug("_registerFileIcon"); _registerFileIcon(fileIconControl); _logger.debug("_setFilterPath"); _setFilterPath(nativityControl); _logger.debug("_setSystemFolder"); _setSystemFolder(nativityControl); _logger.debug("_updateFileIcon"); _updateFileIcon(fileIconControl); _logger.debug("_clearFileIcon"); _clearFileIcon(fileIconControl); _logger.debug("Ready?"); if (bufferedReader.ready()) { _logger.debug("Reading..."); read = bufferedReader.readLine(); _logger.debug("Read {}", read); if (read.length() > 0) { stop = true; } _logger.debug("Stopping {}", stop); } } } catch (IOException e) { _logger.error(e.getMessage(), e); } _logger.debug("Done"); }
From source file:com.github.ivkustoff.app.Application.java
public static void main(String[] args) { if (args != null && args.length > 0) { Path testRoot = Paths.get(args[0]); if (testRoot.toFile().exists()) { System.out.println("Parsing data..."); DirCrawler crawler = new DirCrawler(testRoot).crawl(); System.out.println(crawler.errors()); List<ParsedTopicData> parsedTopicData = crawler.topics(); List<Topic> realTopics = new ArrayList<>(); for (ParsedTopicData topicData : parsedTopicData) { realTopics.add(new RealTopic(topicData).generateTopic()); }/*from w w w . j ava2 s. co m*/ System.out.println("Starting server..."); ConfigurableApplicationContext applicationContext = SpringApplication.run(Application.class, args); applicationContext.getBean(TopicRepository.class).addTopics(realTopics); } } else { System.out.println("Please provide topicRoot directory as program argument"); } }