[JAVA100 example]032, standard input and output

Source: Internet
Author: User

Import java.util.*
Import java.io.*
/**
* <p>title: Callout input Output </p>
* <p> Description: Receives standard keyboard input, and outputs to the screen. </p>
* <p>copyright:copyright (c) 2003</p>
* <p>Filename:standerdIO.java</p>
* @version 1.0
*/
public class standerdio{
/**
*<br> Method Description: Main method
*<br> input parameters:
*<br&   gt; return type:
*/
public static void Main (string[] args) {
Vector vtemp = new vector ();
Boolean flag = true;   
while (flag) {
System.out.print ("input>");
String stemp = "";   
//Read input, system.in means receive keyboard input stream
BufferedReader stdin = new BufferedReader (new InputStreamReader (system.in));
   try{
//read one line of input
Stemp = Stdin.readline ();
}catch (IOException IE) {
System.err.println ("IO error!");   
}
//Parse input command
String scmd= "";
String scontext= "";
int point = Stemp.indexof (":");
if (point==-1) {
Scmd = Stemp.trim ();
}else{
Scmd = stemp.substring (0,point);
Scontext = stemp.substring (point+1);
}
//Add Data
if (Scmd.equalsignorecase ("in")) {
if (scontext.equals ("")) {
System.err.print ln ("This command format is errer!");    
}else{
Vtemp.addelement (scontext);

}//View Results
Else if (scmd.equalsignorecase ("Out")) {
for (int i=0;i<vtemp.size (); i++) {
Syste M.out.println (i+ ":" +vtemp.elementat (i));   
}
}//End
Else if (Scmd.equalsignorecase ("Quit")) {
Flag=false;

else{
System.err.println ("This command don´t run!");
System.out.print ("Use:in:command");
System.out.print ("Use:out");
}
}
}
}

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.