Updated on 2022-08-16 GMT+08:00

Development Idea

Development Idea

According to the previous scenario description, the following provides the basic operations for HDFS files with read, write, and delete operations on the /user/hdfs-examples/test.txt file as an example:

  1. Create a FileSystem object: fSystem.
  2. Call the mkdir interface in fSystem to create a directory.
  3. Call the create interface in fSystem to create an FSDataOutputStream object: out. Use the write method to write data into the object out.
  4. Call the append interface in fSystem to create an FSDataOutputStream object: out. Use the write method to append data into the object out.
  5. Call the open interface in fSystem to create an FSDataInputStream object: in. Use the read method to read files of the object in.
  6. Call the delete interface in fSystem to delete the file.
  7. Call the delete interface in fSystem to delete the folder.