linux - How make directory to file in HDFS Hadoop (Cloudera) java -


i first work hadoop assembly cloudera. need make directory file in linux server hdfs. when use java in cmd linux not create diractory, create file. can me bad can me explain, near code java create diractory in hdfs , file.thank your. sorry bad english)

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 create");     string dir = reader.nextline();      // creating new directory in java, if doesn't exists     file directory = new file(dir);     if (directory.exists()) {         system.out.println("directory 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 create new directory: %s%n", dir);         }     }      // creating new file in java, if not exists     system.out.println("enter file name created ");     string filename = reader.nextline();      file f = new file(filename);     if (f.exists()) {         system.out.println("file 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 create new file: %s%n", f);         }     }      // close scanner prevent resource leak     reader.close();  } 

}

when want make directory on hdfs, command line. try @ command prompt

hadoop fs -mkdir /input 

that should create folder in hdfs called input.

from this site, found this

uri uri=uri.create (“hdfs://host: port/path”); 

which believe should create directory you.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -