📄 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 + -