Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

In this page you can find the example usage for java.lang Integer toString.

Prototype

@HotSpotIntrinsicCandidate
public static String toString(int i) 

Source Link

Document

Returns a String object representing the specified integer.

Usage

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    BigInteger p = new BigInteger(Integer.toString(pValue));
    BigInteger g = new BigInteger(Integer.toString(gValue));
    System.out.println("p = " + p);
    System.out.println("g = " + g);

    BigInteger Xa = new BigInteger(Integer.toString(XaValue));
    BigInteger Xb = new BigInteger(Integer.toString(XbValue));
    System.out.println("Xa = " + Xa);
    System.out.println("Xb = " + Xb);

    BigInteger Ya = g.modPow(Xa, p);
    System.out.println("Ya = " + Ya);

    BigInteger Yb = g.modPow(Xb, p);
    System.out.println("Yb = " + Yb);

    BigInteger Ka = Ya.modPow(Xa, p);
    System.out.println("Users A, K = " + Ka);

    BigInteger Kb = Yb.modPow(Xb, p);
    System.out.println("Users B, K = " + Kb);

}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    int eValue = 79;
    int bitLength = 1024; // KeySize

    BigInteger e = e = new BigInteger(Integer.toString(eValue));

    KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
    kpg.initialize(bitLength);//from   ww w  .  j ava  2  s .c  om
    KeyPair kp = kpg.generateKeyPair();

    KeyFactory kfactory = KeyFactory.getInstance("RSA");
    RSAPublicKeySpec kspec = (RSAPublicKeySpec) kfactory.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class);

    kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign");

    e = new BigInteger(Integer.toString(eValue));
    System.out.println("e =" + e);
    RSAKeyGenParameterSpec param = new RSAKeyGenParameterSpec(bitLength, e);
    kpg.initialize(param);
    kp = kpg.generateKeyPair();

    kfactory = KeyFactory.getInstance("RSA", "SunRsaSign");

    kspec = (RSAPublicKeySpec) kfactory.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class);
}

From source file:Main.java

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

    GregorianCalendar gc = new GregorianCalendar();
    gc.setLenient(false);/*  w  ww  .j  av a2s.  c o m*/
    gc.set(GregorianCalendar.YEAR, 2003);
    gc.set(GregorianCalendar.MONTH, 12);
    gc.set(GregorianCalendar.DATE, 1);

    int m = gc.get(GregorianCalendar.MONTH) + 1;
    int d = gc.get(GregorianCalendar.DATE);
    String mm = Integer.toString(m);
    String dd = Integer.toString(d);
    System.out.println(gc.get(GregorianCalendar.YEAR) + (m < 10 ? "0" + mm : mm) + (d < 10 ? "0" + dd : dd));
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(100);//w w w.j av a  2  s  .  c o m
    for (int i = 0; i < 100; i++) {
        model.addElement(Integer.toString(i));
    }
    JList jlist2 = new JList(model);

    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    frame.setSize(300, 350);
    frame.setVisible(true);

    jlist2.ensureIndexIsVisible(50);
}

From source file:SelectionModeDemo.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(100);/*  ww  w. ja  v a2s. com*/
    for (int i = 0; i < 100; i++) {
        model.addElement(Integer.toString(i));
    }
    JList jlist2 = new JList(model);
    jlist2.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    BigInteger p = new BigInteger(Integer.toString(pValue));
    BigInteger g = new BigInteger(Integer.toString(gValue));
    BigInteger Xa = new BigInteger(Integer.toString(XaValue));
    BigInteger Xb = new BigInteger(Integer.toString(XbValue));

    createKey();// w  w  w .j a v a  2  s .  com

    int bitLength = 512; // 512 bits
    SecureRandom rnd = new SecureRandom();
    p = BigInteger.probablePrime(bitLength, rnd);
    g = BigInteger.probablePrime(bitLength, rnd);

    createSpecificKey(p, g);
}

From source file:Main.java

public static void main(String args[]) {
    JPanel p = new JPanel();

    p.setLayout(new GridLayout(2, 1));
    JList<String> lista = new JList<>(new String[] { "1", "2", "3", "4" });
    p.add(new JScrollPane(lista));
    JComboBox<String> combo = new JComboBox<>();
    for (int i = 0; i < 100; i++) {
        combo.addItem(Integer.toString(i));
        p.add(combo);/*from  w w  w .j  ava 2 s.  com*/
    }

    JFrame f = new JFrame();
    f.getContentPane().add(p, BorderLayout.CENTER);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(200, 200);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Reverse Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(3, 3));
    for (int i = 0; i < 9; i++) {
        JButton button = new JButton(Integer.toString(i));
        frame.add(button);//www.  j a v  a  2s .com
    }
    final Container contentPane = frame.getContentPane();
    Comparator<Component> comp = new Comparator<Component>() {
        public int compare(Component c1, Component c2) {
            Component comps[] = contentPane.getComponents();
            List list = Arrays.asList(comps);
            int first = list.indexOf(c1);
            int second = list.indexOf(c2);
            return second - first;
        }
    };
    FocusTraversalPolicy policy = new SortingFocusTraversalPolicy(comp);
    frame.setFocusTraversalPolicy(policy);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Reverse Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setLayout(new GridLayout(3, 3));

    for (int i = 9; i > 0; i--) {
        JButton button = new JButton(Integer.toString(i));
        frame.add(button, 0);//from   ww  w  .jav  a  2s . c  o  m
    }

    final Container contentPane = frame.getContentPane();
    Comparator<Component> comp = new Comparator<Component>() {
        public int compare(Component c1, Component c2) {
            Component comps[] = contentPane.getComponents();
            List list = Arrays.asList(comps);
            int first = list.indexOf(c1);
            int second = list.indexOf(c2);
            return second - first;
        }
    };

    FocusTraversalPolicy policy = new SortingFocusTraversalPolicy(comp);
    frame.setFocusTraversalPolicy(policy);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Vector<Vector<String>> rowData = new Vector<Vector<String>>();
    Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1"));
    for (int i = 0; i < 2000; i++) {
        rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i))));
    }//from   ww w  .j  av  a 2s .  co  m
    JTable table = new JTable(rowData, columnName);
    JScrollPane scrollPane = new JScrollPane(table);
    JScrollBar vertical = scrollPane.getVerticalScrollBar();
    vertical.setPreferredSize(new Dimension(0, 0));
    f.add(scrollPane);
    f.pack();
    f.setVisible(true);
    JViewport view = scrollPane.getViewport();
    Component[] components = view.getComponents();
    for (int i1 = 0; i1 < components.length; i1++) {
        if (components[i1] instanceof JTable) {
            System.out.println("got");
        }
    }
}