@@ -0,0 +1,1407 @@
+import java.io.*;%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.channels.FileChannel;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0Aimport java.util.List;%0A%0A/**%0A * Created by %E6%9D%8E%E6%81%92%E5%90%8D on 2017/6/8.%0A */%0Apublic class ReadFile %7B%0A%0A    public static void read(File file) %7B%0A%0A        try (BufferedReader reader = new BufferedReader(new FileReader(file))) %7B%0A            while (reader.ready()) %7B%0A                System.out.println(reader.readLine());%0A            %7D%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public static void readByNIO(File file) %7B%0A        try (FileChannel channel = new FileInputStream(file).getChannel()) %7B%0A            ByteBuffer buffer = ByteBuffer.allocate((int) file.length());%0A            channel.read(buffer);%0A            System.out.println(new String(buffer.array()));%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public static void readByNIO2(File file) %7B%0A        try %7B%0A            List%3CString%3E lines = Files.readAllLines(Paths.get(file.toURI()));%0A            for (String line : lines) %7B%0A                System.out.println(line);%0A            %7D%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        File file = new File(%22README.md%22);%0A%0A        read(file);%0A%0A        readByNIO(file);%0A%0A        readByNIO2(file);%0A%0A%0A    %7D%0A%7D%0A

add > io read-file code