java.util.Scanner.ioException()%uA0方法返回最后一个IOException异常由此Scanner基本可读抛出。如果不存在这样的异常,此方法返回null。
声明
以下是java.util.Scanner.ioException()方法的声明
public IOException ioException()
参数
-
NA
返回值
此方法返回抛出此scanner读取的最后一个异常
异常
-
NA
例子
下面的示例演示java.util.Scanner.ioException()方法的用法。
package com.yiibai import java.util.* public class ScannerDemo { public static void main(String[] args) { String s = "Hello World! 3 + 3.0 = 6 " // create a new scanner with the specified String Object Scanner scanner = new Scanner(s) // print the line System.out.println("" + scanner.nextLine()) // check if there is an IO exception System.out.println("" + scanner.ioException()) // close the scanner scanner.close() } }
让我们来编译和运行上面的程序,这将产生以下结果:
Hello World! 3 + 3.0 = 6 null