?? ioinput.java
字號:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 提供輸入輸出等操作,實現與用戶的交互操作
* @author Crise.Lee
* @version 1.0
*/
public class IOInput {
private String url,commLine;
private Integer port;
/**
* 輸入一個綁定到URL
* @return
* @throws IOException
*/
public String inputURL() throws IOException
{
System.out.print("請輸入一個URL:");
url=null;
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
try {
url=input.readLine();
} catch (IOException e) {
//e.printStackTrace();
throw new IOException("輸入URL時候IO發生錯誤。。。");
}
return url;
}
/**
* 輸入一條操作命令
* @return
* @throws IOException
*/
public String inputCommad() throws IOException
{
System.out.print("請輸入一個操作命令:");
commLine=null;
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
try {
commLine=input.readLine();
} catch (IOException e) {
// e.printStackTrace();
throw new IOException("輸入操作的時候IO發生錯誤。。。");
}
return commLine;
}
/**
* 輸入一個端口號
* @return
* @throws IOException
*/
public int inputPort() throws IOException
{
Boolean isnumber=true;
port=0;
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
while(isnumber)
{
try {
System.out.print("請輸入一個端口號:");
port=Integer.valueOf(input.readLine());
isnumber=false;
} catch (NumberFormatException e) {
System.err.print("錯誤原因:輸入的為非整數,請重新輸入一個為整數的端口號:");
input=new BufferedReader(new InputStreamReader(System.in));
isnumber=true;
//e.printStackTrace();
}catch (IOException e) {
//e.printStackTrace();
throw new IOException("輸入端口的時候IO發生錯誤。。。。");
}
}
return port;
}
/**
* 返回端口號
* @return
*/
/**public Integer getPort()
{
return port;
}*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -