public List<String> tokenize(String inputFileName,PrintWriter writer){
  JavaRDD<String> input=readTextFile(inputFileName);
  JavaRDD<String> output=tokenize(input);
  List<String> lines=output.collect();
  for (  String line : lines) {
    writer.write(line);
    writer.write('\n');
  }
  writer.flush();
  return lines;
}

public List < String > tokenize ( String inputFileName , PrintWriter writer ) { JavaRDD < String > input = readTextFile ( inputFileName ) ; JavaRDD < String > output = tokenize ( input ) ; List < String > lines = output . collect ( ) ; for ( String line : lines ) { writer . write ( line ) ; writer . write ( '\n' ) ; } writer . flush ( ) ; return lines ; }
tokenizes a text file and writes the result to a writer .
