提示

Java IO FileReader 使用示例。@ermo

回到上一级

    public static void read() throws IOException {
        char[] array = new char[100];
        String filepath = "src/main/resources/file-writer.txt";
        FileReader reader = new FileReader(filepath);

        try {
            reader.read(array);
            System.out.println("Read from file:");
            System.out.println(array);
        } finally {
            reader.close();
        }
    }

    public static void main(String[] args) throws IOException {
        read();
    }