javaでファイル読み込み

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        if (args.length < 1) {
            System.err.println("Please specify a file name.");
            System.exit(-1);
        }
        try (InputStream in = new FileInputStream(args[0])) {
            byte[] buf = new byte[4096];
            int len;

            while ((len = in.read(buf)) != -1) {
                System.out.write(buf, 0, len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}