commandinput.java
来自「使用java rmi编写的一个议程服务系统」· Java 代码 · 共 86 行
JAVA
86 行
package agendaClient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CommandInput{
private String url,commLine;
private Integer port;
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;
}
/**public String getbaseURL()
{
return baseurl;
}*/
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;
}
/**public String getCommand()
{
return commLine;
}*/
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 + =
减小字号Ctrl + -
显示快捷键?