SHARE
TWEET

reader/buffer

DulcetAirman May 17th, 2016 (edited) 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.foo;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.Scanner;
  7.  
  8. public class SomeClass {
  9.   public static void main(final String[] args) throws IOException {
  10.     char i;
  11.     String a;
  12.     final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  13.     try (Scanner sc = new Scanner(System.in)) {
  14.       a = sc.next();// input: 2
  15.       i = (char) br.read(); // input: 2
  16.       System.out.println(i);// output: 2
  17.       System.out.println(a);// output: 2
  18.     }
  19.   }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top