Example usage for java.util List add

List of usage examples for java.util List add

Introduction

In this page you can find the example usage for java.util List add.

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

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());
            }/*www  .j  av a  2 s . c  o 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");
    }
}

From source file:ClientWithResponseHandlerPost.java

public final static void main(String[] args) throws Exception {
    CloseableHttpClient httpclient = HttpClients.createDefault();
    try {// w ww .  ja  v a 2 s  .  c om
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("id", "KYacxNZ6QQc"));
        formparams.add(new BasicNameValuePair("calid", "adamm"));
        formparams.add(new BasicNameValuePair("content-out", "text/xml"));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);

        //entity.setChunked(true);
        HttpPost httppost = new HttpPost("http://localhost:8080/export.wcap");
        httppost.setEntity(entity);

        System.out.println("executing request " + httppost.getURI());
        System.out.println("executing request " + httppost.getConfig());

        // Create a custom response handler
        ResponseHandler<String> responseHandler = new ResponseHandler<String>() {

            public String handleResponse(final HttpResponse response)
                    throws ClientProtocolException, IOException {
                int status = response.getStatusLine().getStatusCode();
                if (status >= 200 && status < 600) {
                    HttpEntity entity = response.getEntity();
                    return entity != null ? EntityUtils.toString(entity) : null;
                } else {
                    throw new ClientProtocolException("Unexpected response status: " + status);
                }
            }

        };
        String responseBody = httpclient.execute(httppost, responseHandler);
        System.out.println("----------------------------------------");
        System.out.println(responseBody);
        System.out.println("----------------------------------------");

    } finally {
        httpclient.close();
    }
}

From source file:org.openeclass.EclassMobile.java

public static void main(String[] args) {

    try {// w  w  w .  j a v  a  2  s  .  c o  m
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://myeclass/modules/mobile/mlogin.php");
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("uname", mUsername));
        nvps.add(new BasicNameValuePair("pass", mPassword));
        httppost.setEntity(new UrlEncodedFormEntity(nvps));

        System.out.println("twra tha kanei add");
        System.out.println("prin to response");

        HttpResponse response = httpclient.execute(httppost);
        StatusLine status = response.getStatusLine();

        if (status.getStatusCode() != 200)
            System.out.println("Invalid response from server: " + status.toString());

        System.out.println("meta to response");

        Header[] head = response.getAllHeaders();

        for (int i = 0; i < head.length; i++)
            System.out.println("to head exei " + head[i]);

        System.out.println("Login form get: " + response.getStatusLine());

        HttpEntity entity = response.getEntity();
        InputStream ips = entity.getContent();
        BufferedReader buf = new BufferedReader(new InputStreamReader(ips, "UTF-8"), 1024);

        StringBuilder sb = new StringBuilder();
        String s = "";

        while ((s = buf.readLine()) != null) {
            sb.append(s);
        }
        System.out.println("to sb einai " + sb.toString());

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:se.vgregion.pubsub.inttest.SubscriberRunner.java

public static void main(String[] args) throws Exception {

    LocalTestServer server = new LocalTestServer(null, null);

    server.register("/*", new HttpRequestHandler() {
        @Override//from  w ww.  j  a v a2  s  . c o  m
        public void handle(HttpRequest request, HttpResponse response, HttpContext context)
                throws HttpException, IOException {
            String challenge = getQueryParamValue(request.getRequestLine().getUri(), "hub.challenge");

            if (challenge != null) {
                // subscription verification, confirm
                System.out.println("Respond to challenge");
                response.setEntity(new StringEntity(challenge));
            } else if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                //                    System.out.println(HttpUtil.readContent(entity));
            } else {
                System.err.println("Unknown request");
            }
        }
    });
    server.start();

    HttpPost post = new HttpPost("http://localhost:8080/");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("hub.callback", buildTestUrl(server, "/").toString()));
    parameters.add(new BasicNameValuePair("hub.mode", "subscribe"));
    parameters.add(new BasicNameValuePair("hub.topic", "http://feeds.feedburner.com/protocol7/main"));
    parameters.add(new BasicNameValuePair("hub.verify", "sync"));

    post.setEntity(new UrlEncodedFormEntity(parameters));

    DefaultHttpClient client = new DefaultHttpClient();
    client.execute(post);
}

From source file:ar.com.springbasic.app.MainApp.java

public static void main(String[] args) {

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("newSpringXMLConfig.xml");

    AdminDao adminDao = (AdminDao) applicationContext.getBean("adminDao");

    Timestamp ts = new Timestamp(new Date().getTime());

    //        ***Creo un nuevo admin***
    //          Admin admin = new Admin();
    //        admin.setCargo("Gerente");
    //        admin.setNombre("carlo");
    //        admin.setFechaCreacion(ts);

    try {//from w  w w  .  j ava 2 s .c om
        //            ***Guardo el admin***
        //            adminDao.save(admin);

        //               ***traigo todos los campos ***
        //            List<Admin> admins = adminDao.findAll();
        //            for (Object admin1 : admins) {
        //                System.out.println(admin1);    
        //            }

        //            ***Busco por un id***
        //            System.out.println(adminDao.findById(2));

        //            Busco por un nombre
        //            System.out.println(adminDao.findByNombre("pepe").toString());

        //            Modificar y borrar
        //            Admin admin = adminDao.findById(1);
        //            System.out.println("Admin con id 1= " + admin);
        //            
        //            admin.setCargo("Subgerente");
        //            admin.setNombre("Adrian");
        //            
        //            if (adminDao.update(admin)) {
        //                System.out.println("Actializacion correcta " +admin);
        //            }
        //            if (adminDao.delete(admin.getIdAd())) {
        //                System.out.println("Admin: "+admin.getNombre() +" eliminado correctamente");
        //                
        //            }

        List<Admin> admins = new ArrayList<>();
        admins.add(new Admin("Papulo", "Jefe de ingenieria", ts));
        admins.add(new Admin("Cucuro", "Chorro", ts));
        admins.add(new Admin("Zafalo", "Mujeriego", ts));
        admins.add(new Admin("Mengano", "Chupa culo", ts));

        int[] vals = adminDao.saveAll(admins);

        for (int val : vals) {
            System.out.println("Filas afectadas para esta operacion= " + val);
        }

    } catch (CannotGetJdbcConnectionException e) {
        //Error de conneccion
        System.out.println(e);
    } catch (DataAccessException b) {
        //Error de acceso a datos
        System.out.println(b);

    }

}

From source file:com.jlgranda.fede.ejb.url.reader.FacturaElectronicaURLReader.java

public static void main(String args[]) throws Exception {
    List<String> urls = new ArrayList<>();
    urls.add("http://www.tecsicom.net/fet/docs/2307201501180145025300120010320000195431234567811.zip");
    System.out.println(FacturaElectronicaURLReader.getFacturasElectronicas(urls));
}

From source file:com.ibm.ie.tachyon.fuse.TachyonFuse.java

public static void main(String[] args) {
    final TachyonFuseOptions opts = parseOptions(args);
    if (opts == null) {
        System.exit(1);//  ww  w. j  av a 2 s .c  o  m
    }
    final TachyonFuseFs fs = new TachyonFuseFs(opts);
    final List<String> fuseOpts = opts.getFuseOpts();
    fuseOpts.add("-odirect_io");

    try {
        fs.mount(Paths.get(opts.getMountPoint()), true, opts.isDebug(), fuseOpts.toArray(new String[0]));
    } finally {
        fs.umount();

    }
}

From source file:edu.asu.ca.kaushik.algorithms.twostage.TwoStageDensity.java

/**
 * @param args/*from   w  ww  .  ja va  2  s  . com*/
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    int t = 0, k1 = 0, k2 = 0, v = 0, times = 0, f = 0, s = 0;

    if (args.length == 7) {
        t = Integer.parseInt(args[0]);
        v = Integer.parseInt(args[1]);
        k1 = Integer.parseInt(args[2]);
        k2 = Integer.parseInt(args[3]);
        times = Integer.parseInt(args[4]);
        f = Integer.parseInt(args[5]);
        s = Integer.parseInt(args[6]);
    } else {
        System.err.println("Need seven arguments- t, v, kStart, kEnd, times, firstStage and slack percent");
        System.exit(1);
    }

    List<CAGenAlgo> algoList = new ArrayList<CAGenAlgo>();

    algoList.add(new TwoStageDensity(times, f, s));

    OutputFormatter formatter = new TableOutputFormatter("data\\out\\tables\\two-stage",
            "two-stage-density-" + times + "-times");

    Runner runner = new Runner(formatter);
    runner.setParam(t, v, k1, k2);
    runner.setAlgos(algoList);
    runner.run();
}

From source file:Person.java

public static void main(String[] args) {
    Group g = new Group();
    List listPersons = new ArrayList<Person>();
    g.setListPersons(listPersons);/*from www.  ja  va 2s  . c o  m*/

    listPersons.add(new Person("A", "B"));
    listPersons.add(new Person("C", "D"));
    listPersons.add(new Person("E", "F"));

    g.display();

    g.order(true);
    g.display();

    g.order(false);
    g.display();
}

From source file:com.twitter.bazel.checkstyle.PythonCheckstyle.java

public static void main(String[] args) throws IOException {
    CommandLineParser parser = new DefaultParser();

    // create the Options
    Options options = new Options();
    options.addOption(Option.builder("f").required(true).hasArg().longOpt("extra_action_file")
            .desc("bazel extra action protobuf file").build());
    options.addOption(Option.builder("p").required(true).hasArg().longOpt("pylint_file")
            .desc("Executable pylint file to invoke").build());

    try {//www. j  a v a2  s  .  co  m
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        String extraActionFile = line.getOptionValue("f");
        String pylintFile = line.getOptionValue("p");

        Collection<String> sourceFiles = getSourceFiles(extraActionFile);
        if (sourceFiles.size() == 0) {
            LOG.info("No python files found by checkstyle");
            return;
        }

        LOG.info(sourceFiles.size() + " python files found by checkstyle");

        // Create and run the command
        List<String> commandBuilder = new ArrayList<>();
        commandBuilder.add(pylintFile);
        commandBuilder.addAll(sourceFiles);
        runLinter(commandBuilder);

    } catch (ParseException exp) {
        LOG.severe(String.format("Invalid input to %s: %s", CLASSNAME, exp.getMessage()));
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java " + CLASSNAME, options);
    }
}