An internationalized multi-language instance of Java IO stream

Source: Internet
Author: User
Tags locale

http://www.verejava.com/?id=16994875552823

/** Title: Civil Aviation Airline Ticket User Login verification System 1. Keyboard input Select English or Chinese system (1: Chinese, 2: English) 2. Keyboard Enter user name and password 3. The user name and password entered cannot be judged to be null 4. Login to enter the user name and password to verify the idea: 1. Abstract class: 1.1 User 1.2 User management class (Usermanager) 2. Find out the class relationship: 2.1 User--Usermanager 3. Find the Class attribute: 3.1 User (username, password) 4. Find out how: 4.1 User Login Authentication Usermanager{boolean islogin (user user)}*/import java.util.scanner;import java.util.locale;impo RT Java.util.resourcebundle;import Java.text.messageformat;public class testlocaleapplication{public static void main    (string[] args)        {Scanner in=new Scanner (system.in);        SYSTEM.OUT.PRINTLN ("Please choose Chinese or English environment (1: Chinese, 2: English)");        int Number=integer.parseint (In.nextline ());        Create the corresponding national language locale Locale=localefactory.createlocale (number) based on the numbers entered;        ResourceBundle bundle=resourcebundle.getbundle ("Validation", locale);        System.out.println (bundle.getstring ("Inputusername")); String UsernAme=in.nextline ();        System.out.println (bundle.getstring ("Inputpassword"));        String Password=in.nextline (); Input validation if (username==null| |            Username.equals ("")) {System.out.println ("bundle.getstring") ("Validusername");        Return } if (password==null| |            Password.equals ("")) {System.out.println ("bundle.getstring") ("VALIDPASSOWRD");        return;        }//Verify login user user=new user (Username,password);        Usermanager um=new Usermanager (); if (um.islogin (user)) {System.out.println (Messageformat.format (bundle.getstring ("loginsuccess"), username        , username));        } else {System.out.println (bundle.getstring ("Loginfail"));    }}}class user{private String username;    private String password;        Public User (String username,string password) {this.username=username;    This.password=password; } Public String GetUserName () {return this.username;    } public void Setusername (String username) {this.username=username;    } public String GetPassword () {return this.password;    } public void SetPassword (String password) {This.password=password; }}class usermanager{/** User Login Verification */public boolean islogin (user user) {if (User!=null&&us        Er.getusername (). Equals ("admin") &&user.getpassword (). Equals ("1")) {return true;    } return false; }}/** Create a factory for language locale class */class localefactory{/** based on input (1: Create Chinese locale, 2: English locale) */public static L        Ocale Createlocale (int number) {if (number==1) return new Locale ("zh", "CN");        if (number==2) return new Locale ("en", "US");    return null; }}

http://www.verejava.com/?id=16994875552823

An internationalized multi-language instance of Java IO stream

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.