main.java

来自「java的经典例子」· Java 代码 · 共 21 行

JAVA
21
字号
import java.io.FileOutputStream;
import java.io.IOException;

class Main {
    public static void main (String[] args) {
        if (args.length != 1) {
            System.err.println("Usage: java Main <output_file>");
            System.exit(-1);
        }
        try {
            // create file in append mode
            FileOutputStream out = new FileOutputStream(args[0], true);
            byte[] buf = {'h', 'e', 'l', 'l', 'o', '\n'};
            out.write(buf);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?