?? chap7-6.txt
字號:
// 程序7-6
import java.io.*;
public class testThrows {
public static String readString( ) throws IOException{ // 當前方法可能產生異常
int ch;
String r="";
boolean done=false;
while(!done){
ch=System.in.read( );
if(ch<0 || ch==0xd) // 處理回車符中的第一個符號
done=true;
else
r=r+(char)ch;
}
return r;
}
public static void main(String args[ ]) {
String str;
try{
str=readString( );
}catch(IOException e){ // 處理異常
System.out.println("產生了輸入/輸出異常");
return;
}
System.out.println("輸入的整數是:"+Integer.parseInt(str));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -