main.java

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

JAVA
37
字号
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 {
            char[] buf = {'h', 'h', 'e', 'e', 'l', 'l', 'l', 'l', 
                          'o', 'o', '\n', '\n'};
            SkipFilterReader s1 = 
                new SkipFilterReader(new CharArrayReader(buf));

            int howmany;
            if (s1.markSupported()) {
                System.out.println("marking");
                s1.mark(200);
            }
            int ch;
            while ((ch=s1.read()) >= 0) {
                System.out.print((char)ch);
            }
            if (s1.markSupported()) {
                System.out.println("resetting");
                s1.reset();
            }
            while ((ch=s1.read()) >= 0) {
                System.out.print((char)ch);
            }
            s1.close();
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

⌨️ 快捷键说明

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