Java--从键盘读取

//从键盘读取

package Demo;
import java.util.*;
import java.io.*;
public class loop {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        String r = f.readLine();
        System.out.println(r);
    }
}

 

package Demo;
import java.util.*;
import java.io.*;
public class loop {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        String r;
//        System.out.println(r);
        do{
            System.out.println("Input.....");
            r = f.readLine();
            System.out.println(r);
        }while (!r.equals("end"));
    }
}
package Demo;
import java.util.*;
import java.io.*;
public class loop {
    public static void main(String[] args) throws IOException{
        //使用字节流读取数据
        byte[] bytesdata =  new byte[100];
        System.out.println("Input...");
        try{
            System.in.read(bytesdata);
        }catch (IOException e){
            e.printStackTrace();
        }
        System.out.println("your intput is ");
        for (int i = 0; i < bytesdata.length; i++){
            System.out.print((char)bytesdata[i]);
        }
    }
}

 

posted @ 2021-03-08 19:45  朵朵奇fa  阅读(134)  评论(0编辑  收藏  举报