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:net.meltdowntech.steamstats.SteamUser.java

public static void main(String[] args) {
    Util.startTimer();//from   w w w  .j  ava2s . c  o  m
    List<Long> ids = new ArrayList<>();
    ids.add(76561198038145439L);
    List<SteamUser> users = fetchUsers(ids);
    users.get(0).fetchPlaytime();
    users.get(0).fetchLevel();
    Util.printInfo("Playtime " + users.get(0).getPlaytime());
    Util.printInfo("Level " + users.get(0).getLevel());
}

From source file:com.da.img.ClientFormLogin.java

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

    DefaultHttpClient httpclient = new DefaultHttpClient();

    try {//from  w  ww  .  j a  v a2 s.com
        HttpGet httpget = new HttpGet("http://www.soraven.info/index.php");

        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();
        //System.out.println( EntityUtils.toString(entity));
        System.out.println("Login form get: " + response.getStatusLine());
        EntityUtils.consume(entity);

        System.out.println("Initial set of cookies:");
        List<Cookie> cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
            System.out.println("None");
        } else {
            for (int i = 0; i < cookies.size(); i++) {
                System.out.println("-1 " + cookies.get(i).toString());
            }
        }

        HttpPost httpost = new HttpPost("http://www.soraven.info/common/include/login.php");
        Header header1 = new BasicHeader("Accept",
                "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,application/msword, */*");
        Header header2 = new BasicHeader("Referer", "http://www.soraven.info/index.php");
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("p_userid", "bimohani"));
        nvps.add(new BasicNameValuePair("p_passwd", "cw8904"));
        nvps.add(new BasicNameValuePair("x", "12"));
        nvps.add(new BasicNameValuePair("y", "20"));
        httpost.setHeader(header1);
        httpost.setHeader(header2);
        httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

        //Thread.sleep(2000);
        response = httpclient.execute(httpost);
        entity = response.getEntity();

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

        System.out.println(EntityUtils.toString(entity));
        EntityUtils.consume(entity);

        System.out.println("Post logon cookies:");
        cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
            System.out.println("None");
        } else {
            for (int i = 0; i < cookies.size(); i++) {
                System.out.println("-2 " + cookies.get(i).toString());
            }
        }

    } finally {
        // When HttpClient instance is no longer needed,
        // shut down the connection manager to ensure
        // immediate deallocation of all system resources
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JAXBContext jc = JAXBContext.newInstance(Foo.class);

    Foo foo = new Foo();
    List<Bar> bars = new ArrayList<Bar>();
    foo.setBars(bars);//from ww  w .  ja  v a  2  s .  c o  m

    Bar<String> stringBar = new Bar<String>();
    stringBar.setValue("string data");
    bars.add(stringBar);

    Bar<byte[]> binaryBar = new Bar<byte[]>();
    binaryBar.setValue("binary data".getBytes());
    bars.add(binaryBar);

    Marshaller marshaller = jc.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(foo, System.out);
}

From source file:org.switchyard.quickstarts.rules.multi.RulesMultithreadBindingClient.java

/**
 * The main method.//from  w w w.jav a  2s .  c o  m
 *
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {

    List<List<Item>> items = new ArrayList<List<Item>>();

    List<Item> items0 = new ArrayList<Item>();
    items0.add(new Item(1, "DELLXX", 400));
    items0.add(new Item(2, "LENOVO%20XX", 700));
    items0.add(new Item(3, "SAMSUNG%20XX", 750));
    items0.add(new Item(4, "DELLXX", 400));

    List<Item> items1 = new ArrayList<Item>();
    items1.add(new Item(16, "LENOVO%20YY", 1700));
    items1.add(new Item(17, "SAMSUNG%20YY", 1750));
    items1.add(new Item(18, "DELL%20YY", 1400));

    List<Item> items2 = new ArrayList<Item>();
    items2.add(new Item(6, "LENOVO%20ZZ", 380));
    items2.add(new Item(7, "SAMSUNG%20ZZ", 730));
    items2.add(new Item(8, "DELL%20ZZ", 450));

    List<Item> items3 = new ArrayList<Item>();
    items3.add(new Item(9, "LENOVO%20XY", 50));
    items3.add(new Item(10, "SAMSUNG%20XY", 950));
    items3.add(new Item(11, "DELL%20XY", 400));

    List<Item> items4 = new ArrayList<Item>();
    items4.add(new Item(12, "LENOVO%20ZY", 200));
    items4.add(new Item(13, "SAMSUNG%20ZY", 175));
    items4.add(new Item(14, "DELL%20ZY", 100));

    items.add(items0);
    items.add(items1);
    items.add(items2);
    items.add(items3);
    items.add(items4);

    for (int i = 0; i < THREADS; i++) {
        (new Thread(new RulesMultithreadBindingClient(items.get(i), i))).start();
    }
}

From source file:edu.asu.ca.kaushik.algorithms.randomized.lll.GroupLLL.java

public static void main(String[] args) throws IOException {
    int t = 0, k1 = 0, k2 = 0, v = 0, g = -1;

    if (args.length == 5) {
        t = Integer.parseInt(args[0]);
        v = Integer.parseInt(args[1]);
        k1 = Integer.parseInt(args[2]);
        k2 = Integer.parseInt(args[3]);
        g = Integer.parseInt(args[4]);
    } else {/*from   w w  w  . j a va2s.  c  o m*/
        System.err.println("Need 5 arguments- t, v, kStart, kEnd, and group type");
        System.exit(1);
    }

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

    algoList.add(new GroupLLL(g));

    OutputFormatter formatter = new TableOutputFormatter("data\\out\\tables\\lll", "GroupLLL");

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

From source file:Main.java

public static void main(String[] args) {
    List list = new LinkedList();

    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] months = dfs.getMonths();
    for (int i = 0; i < months.length; i++) {
        String month = months[i];
        list.add(month);
    }//  w  w w  . j  a v a2s  . c  o  m

    Collections.sort(list);
    System.out.println("Month Names = " + list);
    int index = Collections.binarySearch(list, "October");
    if (index > 0) {
        System.out.println("Found at index = " + index);
        String month = (String) list.get(index);
        System.out.println("Month = " + month);
    }
}

From source file:GenericsTester.java

public static void main(String[] args) {
    GenericsTester tester = new GenericsTester();

    try {/*from   ww w.j av a2 s  .c  om*/
        tester.testTypeSafeLists(System.out);
        tester.testTypeSafeMaps(System.out);
        tester.testTypeSafeIterators(System.out);
        tester.testTypeSafeReturnValues(System.out);

        List<Integer> ints = new LinkedList<Integer>();
        ints.add(1);
        ints.add(2);
        ints.add(3);
        tester.printList(ints, System.out);

        /** Uncomment for an error
        NumberBox<String> illegal = new NumberBox<String>();
         */
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:in.sc.main.ABC.java

public static void main(String[] args) {
    List list = new ArrayList();
    list.add("1");
    list.add("2");
    list.add("3");
    Collections.reverse(list);//from   w  w w  .  j  a va  2s .  c o m
    list.iterator();
    for (Object obj : reverse(list)) {
        System.out.print(obj + ", ");
    }

    D x = (D) new D();
    if (x instanceof I) {
        System.out.println("I");
    }
    if (x instanceof J) {
        System.out.println("J");
    }
    if (x instanceof C) {
        System.out.println("C");
    }
    if (x instanceof D) {
        System.out.println("D");
    }
    xyz x1 = new xyz("Test");
    int x2 = 111;

    Rank abc = Rank.FIRST;
    System.out.println("" + abc.SECOND);
    final int j = 2;
    switch (x2) {
    case 1:
        System.out.println("1");
        break;
    case 10:
        System.out.println("10");
        break;
    case j:
        System.out.println("2");
        break;
    case 5:
        System.out.println("5");
        break;
    default:
        System.out.println("Default");
        break;
    }
    String str1 = "lower", str2 = "LOWER", str3 = "UPPER";
    str1.toUpperCase();
    str1.replace("LOWER", "UPPER");
    System.out
            .println((str1.equals(str2)) + " " + (str1.equals(str3)) + "  " + str1 + "  " + str2 + "  " + str3);
    for (int i = 0; i < 3; i++) {
        System.out.println("" + i);
        switch (i) {
        case 0:
            break;
        case 1:
            System.out.println("one");
        case 2:
            System.out.println("two");
        case 3:
            System.out.println("three");
        }
    }
    System.out.println("done");
    ABC a = new ABC("a", "b");
    ABC b = new ABC(a);
}

From source file:pt.ua.tm.neji.web.test.TestREST.java

public static void main(String[] args) throws IOException, KeyStoreException, NoSuchAlgorithmException,
        CertificateException, KeyManagementException, UnrecoverableKeyException {

    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    trustStore.load(null, null);/*from  w  w  w  .  j a  va 2  s  .  c  o  m*/

    MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
    sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "utf-8");

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", sf, 8010));

    ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

    String url = "https://localhost:8010/annotate/default/export?tool=becas-webapp&email=bioinformatics@ua.pt";

    // POST
    CloseableHttpClient client = new DefaultHttpClient(ccm, params);

    HttpPost post = new HttpPost(url);
    //post.setHeader("Content-Type", "application/json");

    List<NameValuePair> keyValuesPairs = new ArrayList();
    //keyValuesPairs.add(new BasicNameValuePair("format", "neji"));
    keyValuesPairs.add(new BasicNameValuePair("fromFile", "false"));
    //keyValuesPairs.add(new BasicNameValuePair("groups", "{\"DISO\":true,\"ANAT\":true}"));
    //keyValuesPairs.add(new BasicNameValuePair("groups", "{}"));
    //keyValuesPairs.add(new BasicNameValuePair("groups", "{\"DISO\":true}"));
    //keyValuesPairs.add(new BasicNameValuePair("groups", "{\"ANAT\":true}"));
    keyValuesPairs.add(new BasicNameValuePair("text", text));
    keyValuesPairs.add(new BasicNameValuePair("crlf", "false"));
    post.setEntity(new UrlEncodedFormEntity(keyValuesPairs));

    HttpResponse response = client.execute(post);

    String result = IOUtils.toString(response.getEntity().getContent());

    System.out.println(result);
}

From source file:ImageStringToBlob.java

public static void main(String[] args) {
    Connection conn = null;/*from www .j ava  2 s.  c  om*/

    if (args.length != 1) {
        System.out.println("Missing argument: full path to <oscar.properties>");
        return;
    }

    try {

        FileInputStream fin = new FileInputStream(args[0]);
        Properties prop = new Properties();
        prop.load(fin);

        String driver = prop.getProperty("db_driver");
        String uri = prop.getProperty("db_uri");
        String db = prop.getProperty("db_name");
        String username = prop.getProperty("db_username");
        String password = prop.getProperty("db_password");

        Class.forName(driver);
        conn = DriverManager.getConnection(uri + db, username, password);
        conn.setAutoCommit(true); // no transactions

        /*
         * select all records ids with image_data not null and contents is null
         * for each id fetch record
         * migrate data from image_data to contents
         */
        String sql = "select image_id from client_image where image_data is not null and contents is null";
        PreparedStatement pst = conn.prepareStatement(sql);
        ResultSet rs = pst.executeQuery();
        List<Long> ids = new ArrayList<Long>();

        while (rs.next()) {
            ids.add(rs.getLong("image_id"));
        }

        rs.close();

        sql = "select image_data from client_image where image_id = ?";
        pst = conn.prepareStatement(sql);

        System.out.println("Migrating image data for " + ids.size() + " images...");
        for (Long id : ids) {
            pst.setLong(1, id);
            ResultSet imagesRS = pst.executeQuery();
            while (imagesRS.next()) {
                String dataString = imagesRS.getString("image_data");
                Blob dataBlob = fromStringToBlob(dataString);
                if (writeBlobToDb(conn, id, dataBlob) == 1) {
                    System.out.println("Image data migrated for image_id: " + id);
                }
            }
            imagesRS.close();
        }
        System.out.println("Migration completed.");

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}