📄 basicinput.java
字号:
//******************* start of BasicInput.java
package basicIO;
import java.io.*;
import java.util.StringTokenizer;
public class BasicInput {
public BasicInput() throws IOException {
// st.returnDelims=false;
init( new InputStreamReader( System.in ) );
}
public BasicInput( String f ) throws IOException {
init( new InputStreamReader( new FileInputStream( f ) ) );
diskFile = true;
}
public void close() throws IOException {
if ( diskFile && input != null )
input.close();
}
public boolean eof() throws IOException {
resetBuffer();
return !st.hasMoreTokens();
}
public String getRecord() throws IOException {
resetBuffer();
st = null; // forces a read on next resetBuffer()
return buffer;
}
public String getString() throws IOException {
resetBuffer();
return st.nextToken();
}
public byte getByte() throws IOException {
resetBuffer();
return Byte.parseByte( st.nextToken() );
}
public int getInt() throws IOException {
resetBuffer();
return Integer.parseInt( st.nextToken() );
}
public double getDouble() throws IOException {
resetBuffer();
return Double.parseDouble( st.nextToken() );
}
public char getChar() throws IOException {
resetBuffer();
return st.nextToken().charAt( 0 ); //*** 1st char in String
}
private void init( InputStreamReader in ) throws IOException {
close();
input = new BufferedReader( in );
st = null;
resetBuffer();
}
private void resetBuffer() throws IOException {
if ( st == null || !st.hasMoreTokens() ) {
buffer = input.readLine();
if ( buffer != null )
st = new StringTokenizer( buffer );
}
}
protected BufferedReader input;
private String buffer;
private StringTokenizer st;
private boolean diskFile;
}
//******************* end of BasicInput.java
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -