Reads a long from console - Java Language Basics

Java examples for Language Basics:Console

Description

Reads a long from console

Demo Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static BufferedReader buffer = new BufferedReader(
            new InputStreamReader(System.in));

    /**/*from  www  .j a v a 2  s . c o  m*/
     * Reads a long from console
     * 
     * @return the read long
     * @throws IOException
     *             If an IO error occurs
     */
    public static long readLong() throws IOException {
        return Long.parseLong(buffer.readLine());
    }
}

Related Tutorials