0
0

More than 1 year has passed since last update.

consoleから文字を入力

Posted at

InputStreamReaderにSystem.inを指定してnewすると、console inputとなる

public class Outer {
    public static void main(String[] args) {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader bs = new BufferedReader(is);
        try{
            try(bs) {
                    String s = bs.readLine();
                    System.out.println(s);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
ppp      //me typed
ppp      //show in console
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0