Example usage for java.lang Long MAX_VALUE

List of usage examples for java.lang Long MAX_VALUE

Introduction

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

Prototype

long MAX_VALUE

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

Click Source Link

Document

A constant holding the maximum value a long can have, 263-1.

Usage

From source file:edu.usc.qufd.Main.java

/**
 * The main method.//from  www .j  ava  2 s .co m
 *
 * @param args the arguments
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void main(String[] args) throws IOException {
    if (parseInputs(args) == false) {
        System.exit(-1); //The input files do not exist
    }

    /*
     * Parsing inputs: fabric & qasm file
     */
    PrintWriter outputFile;
    RandomAccessFile raf = null;
    String latencyPlaceHolder;
    if (RuntimeConfig.OUTPUT_TO_FILE) {
        latencyPlaceHolder = "Total Latency: " + Long.MAX_VALUE + " us" + System.lineSeparator();
        raf = new RandomAccessFile(outputFileAddr, "rws");
        //removing the old values in the file
        raf.setLength(0);
        //writing a place holder for the total latency
        raf.writeBytes(latencyPlaceHolder);
        raf.close();

        outputFile = new PrintWriter(new BufferedWriter(new FileWriter(outputFileAddr, true)), true);
    } else { //writing to stdout
        outputFile = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
    }
    /* parsing the input*/
    layout = LayoutParser.parse(pmdFileAddr);
    qasm = QASMParser.QASMParser(qasmFileAddr, layout);

    long totalLatency = qufd(outputFile);

    if (RuntimeConfig.OUTPUT_TO_FILE) {
        outputFile.close();
        //Over writing the place holder with the actual latency
        String latencyActual = "Total Latency: " + totalLatency + " " + layout.getTimeUnit();
        latencyActual = StringUtils.rightPad(latencyActual,
                latencyPlaceHolder.length() - System.lineSeparator().length());
        raf = new RandomAccessFile(outputFileAddr, "rws");
        //Writing to the top of a file
        raf.seek(0);
        //writing the actual total latency in the at the top of the output file
        raf.writeBytes(latencyActual + System.lineSeparator());
        raf.close();
    } else {
        outputFile.flush();
        System.out.println("Total Latency: " + totalLatency + " " + layout.getTimeUnit());
    }

    if (RuntimeConfig.VERBOSE) {
        System.out.println("Done.");
    }
    outputFile.close();
}

From source file:esg.gateway.client.ESGAccessLogClient.java

public static void main(String[] args) {
    String serviceHost = null;//  w w w . jav a  2  s  . c o m
    long startTime = 0;
    long endTime = Long.MAX_VALUE;

    try {
        serviceHost = args[0];
        startTime = Long.parseLong(args[1]);
        endTime = Long.parseLong(args[2]);
    } catch (Throwable t) {
        log.error(t.getMessage());
    }

    try {
        ESGAccessLogClient client = new ESGAccessLogClient();
        if (client.setEndpoint(serviceHost).ping()) {
            List<String[]> results = null;
            results = client.fetchAccessLogData(startTime, endTime);

            System.out.println("---results:[" + (results.size() - 1) + "]---");
            for (String[] record : results) {
                StringBuilder sb = new StringBuilder();
                for (String column : record) {
                    sb.append("[" + column + "] ");
                }
                System.out.println(sb.toString());
            }
        }
        System.out.println("-----------------");
    } catch (Throwable t) {
        log.error(t);
        t.printStackTrace();
    }
}

From source file:Main.java

public static void sleepForever() {
    sleep(Long.MAX_VALUE);
}

From source file:Main.java

public static long nextPositiveLong() {
    Random random = new Random();
    return (long) (random.nextDouble() * Long.MAX_VALUE);
}

From source file:Main.java

static void awaitTermination(ExecutorService threadPool) {
    threadPool.shutdown();/* ww w .j av  a2s.  com*/
    try {
        threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * endless sleep until interrupted.// w  w w .j av  a 2  s.  c  om
 * 
 * @param millis
 * @return true:normal end, false: Interrupted
 */
public final static void endlessSleep() {

    try {
        Thread.sleep(Long.MAX_VALUE);
    } catch (InterruptedException e) {
        // omit
    }
}

From source file:Main.java

public static Long getLongSPR(String key, Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getLong(key, Long.MAX_VALUE);
}

From source file:Main.java

public static int transfer(InputStream input, OutputStream output, long maxLength) throws IOException {
    if (maxLength < 0) {
        maxLength = Long.MAX_VALUE;
    }//ww  w  .  j av  a2 s.c o m
    byte[] buffer = new byte[204800];
    int max = buffer.length;
    if (max > maxLength) {
        max = (int) maxLength;
    }
    int size;
    int total = 0;
    while ((size = input.read(buffer, 0, max)) >= 0) {
        output.write(buffer, 0, size);
        maxLength -= size;
        total += size;
        if (maxLength <= 0) {
            break;
        } else {
            if (max > maxLength) {
                max = (int) maxLength;
            }
        }
    }
    return total;
}

From source file:Main.java

public static int getLineCount(String path) {
    LineNumberReader lnr = null;//from ww w. j  a va 2 s  . c  o m
    try {
        lnr = new LineNumberReader(new FileReader(new File(path)));
        lnr.skip(Long.MAX_VALUE);
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (lnr == null)
        return 0;
    return lnr.getLineNumber();
}

From source file:Main.java

public static <T> long getAndAddRequest(AtomicLongFieldUpdater<T> requested, T object, long n) {
    long current;
    long next;//from w w  w. jav  a 2 s .c  o m
    do {
        current = requested.get(object);
        next = current + n;
        if (next < 0) {
            next = Long.MAX_VALUE;
        }
    } while (!requested.compareAndSet(object, current, next));
    return current;
}