반응형
Hadoop의 분산환경에서 동작할 때 쓰이는 IO는 일반적인 Java와는 다르다.
바로 들어간다면
1. Read
Path는 hdfs에서 제공하는 경로 Class이다.
fs.open(pt)는 hdfs 내 file을 얻는 함수이다.
> https://hadoop.apache.org/docs/r2.2.0/api/org/apache/hadoop/fs/FileSystem.html#o
pen(org.apache.hadoop.fs.Path)
fs를 hadoop에서 얻어온 다음 InputStreamReader를 사용하여 readLine( )으로 읽어올 수 있다.
2. Write
3. 이어쓰기는 아래와 같은 방식으로 할 수 있다.
>readLine( )은 String을 얻어온다. 파일에 다시 쓸 경우 "\n"을 넣어준다.
반응형