FileSystem fs = FileSystem.get(new Configuration()); Path wd = fs.getWorkingDirectory(); System.out.println("Working directory: " + wd.toString());
FileSystem fs = FileSystem.get(new Configuration()); Path wd = fs.getWorkingDirectory(); Path myDir = new Path(wd, "mydir/"); fs.mkdirs(myDir);This example is similar to the previous one, except we also create a new directory within the working directory. We create a Path object representing the new directory by calling the constructor with two arguments, the first being the working directory and the second being the name of the new directory. We then call the mkdirs() method on the fs object to create the directory in the filesystem. In conclusion, the org.apache.hadoop.fs.FileSystem package library in Hadoop provides an abstraction to interact with the filesystems, and the getWorkingDirectory() method allows us to get the current working directory of the filesystem.