main.java
来自「java的经典例子」· Java 代码 · 共 29 行
JAVA
29 行
import java.io.*;
class Main {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: java Main <input_file>");
System.exit(-1);
}
try {
File f = new File(args[0]);
FileInputStream in = new FileInputStream(f);
long size = f.length(); // Get size of file.
in.skip(size/2); // Skip half the file.
int c;
while ((c=in.read()) > -1) // Echo the rest.
System.out.print((char)c);
in.close(); // Close it.
System.out.flush();
} catch (FileNotFoundException e) {
System.err.println(args[0] + " is not found");
} catch (IOException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?