Scanner用法例

import java.util.*;
import java.io.*;
public class TestScanner {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()) {
            int str = in.nextInt();
            if (str==0)
                break;
            else 
                System.out.println(str);
        }
        
        System.out.printf("%7.70f",10/3.0);
        System.out.println();
        byte[] b=new byte[10]; 
        try {
            System.in.read(b);
        }catch (IOException e){
            
        }
        System.out.println(Arrays.toString(b));
        System.out.println("End!");
}
}
原文地址:https://www.cnblogs.com/qqjue/p/2502619.html