📄 readstdio.java
字号:
package codegen;
public class ReadStdIO {
private static java.io.BufferedReader b = null;
private static int c = ' ';
static {
b = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
}
private static void nextChar () throws java.io.IOException {
c = b.read ();
}
public static String readToken () {
if (c < 0)
return null;
StringBuffer buffer = new StringBuffer ();
boolean stop = false;
try {
// jump over blank
while (c > 0 && Character.isWhitespace ((char)c))
nextChar ();
if (c < 0)
return null;
do {
buffer.append ((char)c);
nextChar ();
stop = ((c < 0) || Character.isWhitespace ((char)c));
} while (!stop);
} catch (java.io.IOException io) {
util.Error.e3 ("errors in input");
}
return buffer.toString ();
}
public static String readString () {
try {
return b.readLine ();
} catch (java.io.IOException io) {
util.Error.e3 ("errors in input");
}
return null;
}
public static double readDouble () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Double (s).doubleValue ();
}
public static float readFloat () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Float (s).floatValue ();
}
public static long readLong () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Long (s).longValue ();
}
public static int readInteger () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Integer (s).intValue ();
}
public static short readShort () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Short (s).shortValue ();
}
public static byte readByte () {
String s = readToken ();
if (s == null)
util.Error.e3 ("EOF");
return new Byte (s).byteValue ();
}
public static char readCharacter () {
try {
nextChar ();
int cc = c;
if (cc < 0)
util.Error.e3 ("EOF");
else
nextChar ();
return (char)cc;
} catch (java.io.IOException io) {
util.Error.e3 ("errors in input");
}
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -