How to read first line of files in a directory using java cascading? -


i'm working on project learn cascading, , i'm stumped on problem. cascading doesn't seem have read first line of each individual file in directory, need in order discover content type text analysis. i've looked through cascading api documentation several hours, , nothing has jumped out me useful, , google doesn't produce similar question on forum.

i'd avoid running jar each file individually. so, instead of:

hadoop jar myapp.jar this.package.myapp inputpath/file.txt outputpath/ 

i'd this:

hadoop jar myapp.jar this.package.myapp inputpath/ outputpath/ 

i'll answer own question here. turns out using cascading libraries read first line single file @ time in directory not best use. ended switching org.apache.hadoop , wrote following code (this inside main method):

string inputpath = args[0]; path inputdir = new path(inputpath); filesystem lfs = filesystem.get(new congifuration()); filestatus[] files = lfs.liststatus(inputdir); for(int x=0; x < files.length; x++){     bufferedreader br = new bufferedreader(new inputstreamreader(lfs.open(files[x].getpath()));     string line = br.readline(); } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -