Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

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

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:Main.java

public static void main(String args[]) {
    NumberFormat formatter = new DecimalFormat();

    int maxinteger = Integer.MAX_VALUE;
    System.out.println(maxinteger);
    formatter = new DecimalFormat("0.######E0");
    System.out.println(formatter.format(maxinteger));

    formatter = new DecimalFormat("0.#####E0");
    System.out.println(formatter.format(maxinteger));

    int mininteger = Integer.MIN_VALUE;
    System.out.println(mininteger);

    formatter = new DecimalFormat("0.######E0");
    System.out.println(formatter.format(mininteger));

    formatter = new DecimalFormat("0.#####E0");
    System.out.println(formatter.format(mininteger));

    double d = 0.12345;
    formatter = new DecimalFormat("0.#####E0");
    System.out.println(formatter.format(d));

    formatter = new DecimalFormat("000000E0");
    System.out.println(formatter.format(d));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("c:\\a.bat");
    InputStream is = new FileInputStream(file);

    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        System.out.println("File is too large");
    }//from  w w  w .  ja  v a  2  s .  co  m

    byte[] bytes = new byte[(int) length];

    int offset = 0;
    int numRead = 0;
    while (numRead >= 0) {
        numRead = is.read(bytes, offset, bytes.length - offset);
        offset += numRead;
    }

    if (offset < bytes.length) {
        throw new IOException("Could not completely read file " + file.getName());
    }
    is.close();
    System.out.println(new String(bytes));
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();

    Box b = Box.createVerticalBox();

    JTextField field1 = new JTextField();
    JTextField field2 = new JTextField();
    field1.setMaximumSize(new Dimension(Integer.MAX_VALUE, field1.getPreferredSize().height));
    field2.setMaximumSize(new Dimension(Integer.MAX_VALUE, field2.getPreferredSize().height));
    b.add(field1);//w  w w. ja v a 2  s  .c o m
    b.add(field2);

    b.add(Box.createVerticalGlue());

    f.setContentPane(b);
    f.setSize(500, 200);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println("Byte.MIN = " + Byte.MIN_VALUE);
    System.out.println("Byte.MAX = " + Byte.MAX_VALUE);
    System.out.println("Short.MIN = " + Short.MIN_VALUE);
    System.out.println("Short.MAX = " + Short.MAX_VALUE);
    System.out.println("Integer.MIN = " + Integer.MIN_VALUE);
    System.out.println("Integer.MAX = " + Integer.MAX_VALUE);
    System.out.println("Long.MIN = " + Long.MIN_VALUE);
    System.out.println("Long.MAX = " + Long.MAX_VALUE);
    System.out.println("Float.MIN = " + Float.MIN_VALUE);
    System.out.println("Float.MAX = " + Float.MAX_VALUE);
    System.out.println("Double.MIN = " + Double.MIN_VALUE);
    System.out.println("Double.MAX = " + Double.MAX_VALUE);
}

From source file:Main.java

public static void main(String args[]) {

    System.out.println("Min byte value   = " + Byte.MIN_VALUE);
    System.out.println("Max byte value   = " + Byte.MAX_VALUE);
    System.out.println("Min short value  = " + Short.MIN_VALUE);
    System.out.println("Max short value  = " + Short.MAX_VALUE);
    System.out.println("Min int value    = " + Integer.MIN_VALUE);
    System.out.println("Max int value    = " + Integer.MAX_VALUE);
    System.out.println("Min float value  = " + Float.MIN_VALUE);
    System.out.println("Max float value  = " + Float.MAX_VALUE);
    System.out.println("Min double value = " + Double.MIN_VALUE);
    System.out.println("Max double value = " + Double.MAX_VALUE);
}

From source file:MainClass.java

public static void main(String args[]) {
    try {//w w  w . j a v  a  2 s .  c o  m

        FileOutputStream fos = new FileOutputStream(args[0]);

        DataOutputStream dos = new DataOutputStream(fos);

        dos.writeBoolean(false);
        dos.writeByte(Byte.MAX_VALUE);
        dos.writeChar('A');
        dos.writeDouble(Double.MAX_VALUE);
        dos.writeFloat(Float.MAX_VALUE);
        dos.writeInt(Integer.MAX_VALUE);
        dos.writeLong(Long.MAX_VALUE);
        dos.writeShort(Short.MAX_VALUE);

        fos.close();
    } catch (Exception e) {
        System.out.println("Exception: " + e);
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String filename = "test.dat";

    RandomAccessFile raf1 = new RandomAccessFile(filename, "rw");
    FileChannel fc1 = raf1.getChannel();

    RandomAccessFile raf2 = new RandomAccessFile(filename, "rw");
    FileChannel fc2 = raf2.getChannel();

    System.out.println("Grabbing first lock");
    FileLock lock1 = fc1.lock(0L, Integer.MAX_VALUE, false);

    System.out.println("Grabbing second lock");
    FileLock lock2 = fc2.lock(5, 10, false);

    System.out.println("Exiting");
}

From source file:Test.java

public static void main(String[] args) {
    try {/* ww  w.j a v a 2 s .  c  om*/
        Path source = Paths.get("/home");
        Path target = Paths.get("/backup");
        Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
                new CopyDirectory(source, target));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:com.alibaba.dubbo.examples.heartbeat.HeartbeatConsumer.java

public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            HeartbeatConsumer.class.getPackage().getName().replace('.', '/') + "/heartbeat-consumer.xml");
    context.start();//from  w w w .  ja v a  2 s  .c  o  m
    HelloService hello = (HelloService) context.getBean("helloService");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        System.out.println(hello.sayHello("kimi-" + i));
        Thread.sleep(10000);
    }
}

From source file:com.alibaba.dubbo.examples.merge.MergeConsumer.java

public static void main(String[] args) throws Exception {
    String config = MergeConsumer.class.getPackage().getName().replace('.', '/') + "/merge-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();/*from w  ww  .j a  v a 2 s  .c o  m*/
    MergeService mergeService = (MergeService) context.getBean("mergeService");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        try {
            List<String> result = mergeService.mergeResult();
            System.out.println("(" + i + ") " + result);
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}