?? countspace.java
字號:
import java.io.*; //計算文件中的字符數和空白字符數
class CountSpace {
public static void main(String[] args) throws IOException {
InputStream in;
if (args.length == 0) {
in = System.in;
}
else {
in = new FileInputStream(args[0]);
}
int ch;
int total;
int spaces = 0;
for (total = 0; (ch = in.read()) != -1; total++) {
if (Character.isSpace( (char) ch)) {
spaces++;
}
System.out.println(total + "chars," + spaces + "spaces");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -