List of usage examples for java.util List add
boolean add(E e);
From source file:Main.java
public static void main(String[] argv) { List<DayOfWeek> list = new ArrayList<>(); for (Month month : Month.values()) { DayOfWeek day = LocalDate.now().withYear(2010).with(month).with(TemporalAdjusters.lastDayOfMonth()) .getDayOfWeek();/* w ww . j a v a 2 s .c o m*/ list.add(day); } System.out.println(list); }
From source file:com.redhat.satellite.search.DeleteIndexes.java
/** * @param args/* w w w .j a v a 2 s .c o m*/ */ public static void main(String[] args) { try { Configuration config = new Configuration(); DatabaseManager databaseManager = new DatabaseManager(config); String indexWorkDir = config.getString("search.index_work_dir", null); if (StringUtils.isBlank(indexWorkDir)) { log.warn("Couldn't find path for where index files are stored."); log.warn("Looked in config for property: search.index_work_dir"); return; } List<IndexInfo> indexes = new ArrayList<IndexInfo>(); indexes.add(new IndexInfo("deleteLastErrata", indexWorkDir + File.separator + "errata")); indexes.add(new IndexInfo("deleteLastPackage", indexWorkDir + File.separator + "package")); indexes.add(new IndexInfo("deleteLastServer", indexWorkDir + File.separator + "server")); indexes.add(new IndexInfo("deleteLastHardwareDevice", indexWorkDir + File.separator + "hwdevice")); indexes.add(new IndexInfo("deleteLastSnapshotTag", indexWorkDir + File.separator + "snapshotTag")); indexes.add(new IndexInfo("deleteLastServerCustomInfo", indexWorkDir + File.separator + "serverCustomInfo")); indexes.add(new IndexInfo("deleteLastXccdfIdent", indexWorkDir + File.separator + "xccdfIdent")); for (IndexInfo info : indexes) { deleteQuery(databaseManager, info.getQueryName()); if (!deleteIndexPath(info.getDirPath())) { log.warn("Failed to delete index for " + info.getDirPath()); } } } catch (SQLException e) { log.error("Caught Exception: ", e); if (e.getErrorCode() == 17002) { log.error("Unable to establish database connection."); log.error("Ensure database is available and connection details are " + "correct, then retry"); } System.exit(1); } catch (IOException e) { log.error("Caught Exception: ", e); System.exit(1); } log.info("Index files have been deleted and database has been cleaned up, " + "ready to reindex"); }
From source file:com.leonarduk.finance.analysis.BuyAndSellSignalsToChart.java
public static void main(final String[] args) throws IOException { // Getting the time series final StockFeed feed = new IntelligentStockFeed(); final String ticker = "ISXF"; final Stock stock = feed.get(Instrument.fromString(ticker), 1).get(); final TimeSeries series = TimeseriesUtils.getTimeSeries(stock, 1); // Building the trading strategy final List<AbstractStrategy> strategies = new ArrayList<>(); strategies.add(GlobalExtremaStrategy.buildStrategy(series)); strategies.add(MovingMomentumStrategy.buildStrategy(series, 12, 26, 9)); strategies.add(SimpleMovingAverageStrategy.buildStrategy(series, 12)); strategies.add(SimpleMovingAverageStrategy.buildStrategy(series, 20)); strategies.add(SimpleMovingAverageStrategy.buildStrategy(series, 50)); BuyAndSellSignalsToChart.displayBuyAndSellChart(series, strategies, stock.getName()); }
From source file:com.fjn.helper.common.util.StringUtil.java
public static void main(String[] args) { List list = new ArrayList(); for (int i = 0; i < 10; i++) list.add("test"); String src = StringUtil.collectionToString(list, ", "); log.info(src);/*w w w .j a v a 2 s .com*/ for (Object object : StringUtil.toList(src, ", ")) { log.info(object.toString()); } log.info(StringUtil.isNull("") + ""); log.info(StringUtil.isNull(" ") + ""); log.info(StringUtil.isNull(null) + ""); log.info(StringUtil.isNull("\n") + ""); }
From source file:Main.java
License:asdf
public static void main(String[] args) { int howManyWords = 2; List<String> listOfWords = new ArrayList<>(); Random random = new Random(); listOfWords.addAll(Arrays.asList(randomMessages)); List<String> selectedRandomMessages = new ArrayList<>(); for (int i = 0; i < howManyWords; i++) { int randomNumber = random.nextInt(listOfWords.size()); String randomItem = listOfWords.get(randomNumber); selectedRandomMessages.add(randomItem); listOfWords.remove(randomItem);/* w w w. j a v a 2 s . c om*/ } System.out.println(selectedRandomMessages); }
From source file:org.springside.examples.schedule.TransferOaDataToGx.java
public static void main(String[] args) { // // ww w. j ava2s. c o m // // ? // HttpPost httpPost = new HttpPost("http://gxoa.cc/login!login.do?userName=&userPassword=gxuser&loginState=1"); // // // ?connection poolclient // RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20 * 1000) // .setConnectTimeout(20 * 1000).build(); // // CloseableHttpClient httpClient = HttpClientBuilder.create().setMaxConnTotal(20).setMaxConnPerRoute(20) // .setDefaultRequestConfig(requestConfig).build(); // try { // CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); // System.out.println(IOUtils.toString(closeableHttpResponse.getEntity().getContent(), "UTF-8")); // HttpGet httpGet = new HttpGet("http://gxoa.cc/attachmentDownload.do?filePath=2010-07/2010-07-28-4bdd9279-c09e-4b68-80fc-c9d049c6bdfc-GXTC-1005124--??20091062.rar"); // CloseableHttpResponse closeableHttpResponseFile = httpClient.execute(httpGet); // //FileOutputStream fileOutputStream = new FileOutputStream(new File("D:\")); // System.out.println(IOUtils.toString(closeableHttpResponseFile.getEntity().getContent(), "UTF-8")); // // // } catch (ClientProtocolException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // HttpPost httpPost = new HttpPost("http://219.239.33.123:9090/quickstart/api/getFileFromFTP"); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("filePath", "2015-04/2015-04-28-718f376f-b725-4e18-87e2-43e30124b2b5-GXTC-1506112-&-.rar")); String salt = "GXCX_OA_SALT"; long currentTime = ((new Date().getTime() * 4 + 2) * 5 - 1) * 8 + 3;// by yucy String key = salt + currentTime; nvps.add(new BasicNameValuePair("key", Base64.encodeBase64String(key.getBytes()))); try { httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8")); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // ?connection poolclient RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20 * 1000) .setConnectTimeout(20 * 1000).build(); CloseableHttpClient httpClient = HttpClientBuilder.create().setMaxConnTotal(20).setMaxConnPerRoute(20) .setDefaultRequestConfig(requestConfig).build(); try { CloseableHttpResponse closeableHttpResponseFile = httpClient.execute(httpPost); FileUtils.writeByteArrayToFile(new File("D:/upload/templateBulletin.rar"), IOUtils.toByteArray(closeableHttpResponseFile.getEntity().getContent())); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //TODO ? //FileUtils.writeByteArrayToFile( file, FileUtils.readFileToByteArray( new File("D:/upload/templateBulletin.zip") ) ); }
From source file:edu.cmu.tetrad.cli.data.sim.DiscreteTabularData.java
/** * @param args the command line arguments *//* w w w. ja va 2s .co m*/ public static void main(String[] args) { if (args == null || args.length == 0 || Args.hasLongOption(args, "help")) { Args.showHelp("simulate-discrete-data", MAIN_OPTIONS); return; } try { CommandLineParser cmdParser = new DefaultParser(); CommandLine cmd = cmdParser.parse(MAIN_OPTIONS, args); numOfVars = Args.getIntegerMin(cmd.getOptionValue("variable"), 0); numOfCases = Args.getIntegerMin(cmd.getOptionValue("case"), 0); edgeFactor = Args.getDoubleMin(cmd.getOptionValue("edge"), 1.0); } catch (ParseException exception) { System.err.println(exception.getLocalizedMessage()); Args.showHelp("simulate-discrete-data", MAIN_OPTIONS); System.exit(-127); } List<Node> vars = new ArrayList<>(); for (int i = 0; i < numOfVars; i++) { vars.add(new ContinuousVariable("X" + i)); } Graph graph = GraphUtils.randomGraphRandomForwardEdges(vars, 0, (int) (numOfVars * edgeFactor), 30, 12, 15, false, true); BayesPm pm = new BayesPm(graph, 3, 3); BayesIm im = new MlBayesIm(pm, MlBayesIm.RANDOM); DataSet data = im.simulateData(numOfCases, false); String[] variables = data.getVariableNames().toArray(new String[0]); int lastIndex = variables.length - 1; for (int i = 0; i < lastIndex; i++) { System.out.printf("%s,", variables[i]); } System.out.printf("%s%n", variables[lastIndex]); DataBox dataBox = ((BoxDataSet) data).getDataBox(); VerticalIntDataBox box = (VerticalIntDataBox) dataBox; // int[][] matrix = box.getVariableVectors(); // int numOfColumns = matrix.length; // int numOfRows = matrix[0].length; // int[][] dataset = new int[numOfRows][numOfColumns]; // for (int i = 0; i < matrix.length; i++) { // for (int j = 0; j < matrix[i].length; j++) { // dataset[j][i] = matrix[i][j]; // } // } // for (int[] rowData : dataset) { // lastIndex = rowData.length - 1; // for (int i = 0; i < lastIndex; i++) { // System.out.printf("%d,", rowData[i]); // } // System.out.printf("%s%n", rowData[lastIndex]); // } }
From source file:Main.java
public static void main(String args[]) throws Exception { Order o = new Order(); o.setCustId(123);//ww w. j a va 2s . c o m o.setDescription("New order"); o.setOrderDate(new Date()); List<Item> items = new ArrayList<Item>(); Item i = new Item(); i.setName("PC"); i.setQty(10); items.add(i); i = new Item(); i.setName("Box"); i.setQty(4); items.add(i); o.setItems(items); // Write it JAXBContext ctx = JAXBContext.newInstance(Order.class); Marshaller m = ctx.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); StringWriter sw = new StringWriter(); m.marshal(o, sw); sw.close(); System.out.println(sw.toString()); // Read it back JAXBContext readCtx = JAXBContext.newInstance(Order.class); Unmarshaller um = readCtx.createUnmarshaller(); Order newOrder = (Order) um.unmarshal(new StringReader(sw.toString())); System.out.println(newOrder); }
From source file:es.eucm.eadventure.tracking.prv.service.TrackingPoster.java
public static void main(String[] args) { TrackingPoster poster = new TrackingPoster("backend-ea.e-ucm.es/api/sessions/", "snapshots", "chunks"); System.out.println(poster.openSession()); List<GameLogEntry> entries = new ArrayList<GameLogEntry>(); entries.add(new GameLogEntry(500, "test1")); entries.add(new GameLogEntry(700, "test2")); entries.add(new GameLogEntry(800, "test3")); System.out.println(poster.sendChunk(entries)); }
From source file:eu.riscoss.dataproviders.Main.java
public static void main(String[] args) { List<String> components = new ArrayList<String>(); components.add("XWiki"); components.add("WebLab"); components.add("SAT4J"); components.add("Easybeans"); components.add("SpagoBI"); components.add("ASM"); components.add("Docdoku"); components.add("Joram"); components.add("Rubis"); // components.add("test"); // components.add("Activae"); String[] s = new String[4]; s[0] = "-rdr"; // s[1] = "http://riscoss-platform.devxwiki.com/rdr"; //M24 RDR // s[1] = "http://riscossplatform.ow2.org:8080/riscoss-rdr"; //OW2instance RDR s[1] = "http://151.80.95.66:8080/riscoss-rdr"; //OW2instance RDR s[2] = "-properties"; for (String component : components) { s[3] = "Riscossconfig_" + component + ".properties"; exec_single(s);//from w ww.ja va2s . co m } }