java - How to read file in the same project when I do MapReduce -
i need use mapreduce read contents orc files, @ same time, hope when program launched, can automatically load 1 file locates in same jar package of mapreduce program.
my tree folders listed below:
mrproj/ ├── bin │ ├── com │ │ ├── folder ├── **file_i_want_to_readin.dat** ├── lib │ ├── jar01 │ ├── jar02 │ ├── .... └── src ├── com │ ├── **my_mapreduce_folder** ├── **mr.java**
there no problem me read orc files on hdfs, seems when running mapreduce, program can not locate file: "file_i_want_to_readin.dat".
the codes read file listed below:
public static hashmap<string, string> readbinaryfile(string inputdir) { hashmap<string, string> opt = new hashmap<string, string>(); string k = ""; try { datainputstream dis = new datainputstream(new bufferedinputstream(new fileinputstream(new file(inputdir)))); while (dis.available() > 0) { k = dis.readutf(); ... other codes ... } dis.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } return opt; }
Comments
Post a Comment