2012年7月13日 星期五

JAVA 建盤輸入



import java.io.*;

public class app2_1
{
public static void main(String args[]) throws IOException
{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
System.out.println("請輸入數字 ");
String S1 = b.readLine();
System.out.println("輸入數字為 " + S1);
}
}




java.io
Class BufferedReader

java.lang.Object
  extended byjava.io.Reader
      extended byjava.io.BufferedReader
Direct Known Subclasses:
LineNumberReader

 StringreadLine()
          Read a line of text.


readLine

public String readLine()
                throws IOException
Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

沒有留言:

張貼留言