티스토리 뷰

공부

[Java] read in HDFS files

seunggabi 승가비 2020. 2. 21. 23:18
public static void main(String[] args) throws IOException {

    Configuration conf = new Configuration();
    conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml"));
    conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml"));

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the file path...");
    String filePath = br.readLine();

    Path path = new Path(filePath);
    FileSystem fs = path.getFileSystem(conf);
    FSDataInputStream inputStream = fs.open(path);
    System.out.println(inputStream.available());
    fs.close();
}

[출처] https://stackoverflow.com/questions/17072543/reading-hdfs-and-local-files-in-java

'공부' 카테고리의 다른 글

[Java] JSTL foreach  (0) 2020.02.21
[Java] 1.0E-4 to 0.0001  (0) 2020.02.21
[Java] read in HDFS files  (0) 2020.02.21
[Java] Collection.joining()  (0) 2020.02.13
[Linux] Check open port  (0) 2020.02.13
[Python] Install pycurl  (0) 2020.02.13
댓글
댓글쓰기 폼