Creating files and directories in java

Code to create files ,directories and to create multiple files is below

  try {
     //To create a file we use the code below
     //Please note that to write to this file we need to create a channel so there is no point in creating a file like the one below.
     //But the method is there for knowledge sake.
        Path fileToCreate = FileSystems.getDefault().getPath("Examples", "file2.txt");
        Files.createFile(fileToCreate);
     
      //Now lets create a directory
        Path directoryToCreate = FileSystems.getDefault().getPath("Examples", "Dir4");
        Files.createDirectory(directoryToCreate);

      //Now lets create multiple directories in one go i.e dir 4 ,dir 5,dir 6 all in one go in dir 3

       Path directoriesToCreate = FileSystems.getDefault().getPath("Examples", "Dir2\\Dir3\\Dir4\\Dir5\\Dir6");
       Files.createDirectories(directoriesToCreate);

       //or we can do something like this
       //Path directoriesToCreate1 = FileSystems.getDefault().getPath("Examples\\Dir2\\Dir3\\Dir4\\Dir5\\Dir6\\Dir7");
       //  Files.createDirectories(directoriesToCreate1);
    
       catch(IOException e){
           System.out.println(e.getMessage());
       }
   }