title: How make directory to file in HDFS Hadoop (Cloudera) java
body: <p>I first work with Hadoop assembly Cloudera.
  I need to make directory to file in Linux server with HDFS.
  But when i use java in cmd Linux it not create diractory, but create file.
  Can you help me what i do bad can you me explain, near my code java to create diractory in hdfs and file.Thank your. Sorry for bad English)</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import java.util.Scanner;
  
  public class FileDemo {
  
  public static void main(String args[]) throws IOException {
  
      Scanner reader = new Scanner(System.in);
      boolean success = false;
  
      System.out.println("Enter path of directory to create");
      String dir = reader.nextLine();
  
      // Creating new directory in Java, if it doesn't exists
      File directory = new File(dir);
      if (directory.exists()) {
          System.out.println("Directory already exists ...");
  
      } else {
          System.out.println("Directory not exists, creating now");
  
          success = directory.mkdir();
          if (success) {
              System.out.printf("Successfully created new directory : %s%n", dir);
          } else {
              System.out.printf("Failed to create new directory: %s%n", dir);
          }
      }
  
      // Creating new file in Java, only if not exists
      System.out.println("Enter file name to be created ");
      String filename = reader.nextLine();
  
      File f = new File(filename);
      if (f.exists()) {
          System.out.println("File already exists");
  
      } else {
          System.out.println("No such file exists, creating now");
          success = f.createNewFile();
          if (success) {
              System.out.printf("Successfully created new file: %s%n", f);
          } else {
              System.out.printf("Failed to create new file: %s%n", f);
          }
      }
  
      // close Scanner to prevent resource leak
      reader.close();
  
  }
  </code></pre>
  
  <p>}</p>