package com.liu.scanner;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
//创建一个扫描对象,用于接收键盘数据
Scanner scanner = new Scanner(System.in);
System.out.println("请输入:");
//判断用户有没有输入字符串
if (scanner.hasNext()){
//使用next方式接收
String sty = scanner.next();
System.out.println("输入为:"+ sty);
}
//凡是属于IO流的类如果不关闭会一直占用资源,要养成好习惯用完就关掉
scanner.close();
}
}
相关文章
- 11-07Scanner使用
- 11-07CAT ET III Caterpillar Scanner Features
- 11-07CAT ET III Caterpillar Scanner Features
- 11-07spark shc hbase 超时问题 hbase.client.scanner.timeout.period 配置
- 11-07org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next tok
- 11-07org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next tok
- 11-07org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key 报错解决方法
- 11-07Scanner 与 Readable 的read()方法
- 11-07burpsuit之Spider、Scanner、Intruder模块
- 11-07流程控制Day01—用户交互Scanner