?? formattedinput.java
字號:
import java.io.*;
public class FormattedInput
{
// Method to read an int value
public int intRead()
{
try
{
for(int i = 0; i < 5; i++)
{
if(tokenizer.nextToken() == tokenizer.TT_NUMBER &&
tokenizer.nval==(double)((long)tokenizer.nval))
return (int)tokenizer.nval; // Value is integral, so return as int
else
{
System.out.println("Incorrect input: " + tokenizer.sval +
" Re-enter an integer");
continue; // Retry the read operation
}
}
System.out.println("Five failures reading an int value" +
" - program terminated");
System.exit(1); // End the program
return 0;
}
catch(IOException e) // Error reading in nextToken()
{
System.out.println(e); // Output the error
System.exit(1); // End the program
return 0;
}
}
// plus methods to read various other data types...
// Object to tokenize input from the standard input stream
private StreamTokenizer tokenizer = new StreamTokenizer(
new InputStreamReader(System.in));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -