org.apache.hadoop.fs.FsUrlStreamHandlerFactoryを使用する事でjava.net.URLからHDFSにアクセスしてデータを読み取ったりする事が出来る

import java.net.URL;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;

public class Client {
    public static void main(String[] args) throws Exception {
        URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
        URL url = new URL("hdfs://localhost:9000/user/kinjouj/input/data.txt");

        InputStream is = null;
        BufferedReader br = null;

        try {
            is = url.openStream();
            br = new BufferedReader(new InputStreamReader(is));

            String str;

            while((str = br.readLine()) != null) {
                System.out.println(str);
            }
        } catch(Exception e) {
            e.printStackTrace();
        } finally {
            if(br != null) {
                br.close();
            }
            if(is != null) {
                is.close();
            }
        }
    }
}

備考: org.apache.hadoop.fs.FileSystemを利用してアクセスする

import java.net.URI;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class Client {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.setStrings("fs.default.name", "hdfs://localhost:9000");

        FileSystem fs = FileSystem.get(conf);

        InputStream is = null;
        BufferedReeder br = null;

        try {
            is = fs.open(new Path("hdfs://localhost:9000/user/kinjouj/input/data.txt");
            br = new BufferedReader(new InputStreamReader(is));

            String str;

            while((str = br.readLine()) != null) {
                System.out.println(str);
            }
        } catch(Exception e) {
            e.printStackTrace();
        } finally {
            if(br != null) {
                br.close();
            }
            if(is != null) {
                is.close();
            }
        }
    }
}