Two ways for Java console input

Source: Internet
Author: User
two ways for Java console input Code Display
/** * Java console input two ways <br> * Scanner Scanner = new Scanner (system.in);//jdk1.5 followed by <br> * BufferedReader buf  Feredreader = new BufferedReader (new InputStreamReader (system.in)); <br> * * * Note Research under System this class * * @author

    XUYI3 * @ June 30, 2016 @ Morning 10:43:26 * @SystemTest * @ Feature Description:<br> * @ Spring Wind ten not as you * @ remarks/public class Systemtest { @Test a simple input stream after the public void Testscaner () {//jdk1.5), which supports read Scanner for multiple data types Scanner = new Scanner (system.in
        );
        String line = null;
                while (line = Scanner.nextline ())!= null) {if (' Bey '. Equals (line)) {scanner.close ();
            Break
        } System.out.println ("copy:" + line); @Test public void Testsystem () throws Exception {//jdk1.5 Its encapsulated console output stream BufferedReader bu
        Fferedreader = new BufferedReader (new InputStreamReader (system.in));
        String line = null; while (line = Bufferedreader.readliNE ())!= null) {if ("Bey". Equals (line)) {bufferedreader.close ();
            Break
        } System.out.println ("copy:" + line);
 }
    }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.