learning java 转换流

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class KeyinTest {
    public static void main(String[] args) throws IOException {
        var reader = new InputStreamReader(System.in);
        var br = new BufferedReader(reader);
        {
            String line = null;
            while ((line = br.readLine()) != null){
                if (line.equals("exit")){
                    System.exit(0);
                }
                System.out.println("readline content:" + line);
            }

        }

    }
}

output:

adddd
readline content:adddd
dasdf
readline content:dasdf
exit

 

posted @ 2019-08-05 13:29  嵌入式实操  阅读(83)  评论(0编辑  收藏  举报