private static File[] getFiles(String directory, String[] files){
  
    File[] inputFiles = null;
    
    if(directory != null){
      File dir = new File(directory);
      if (!dir.exists() || !dir.isDirectory()){
        System.out.println("Directory parameter " + directory + " does not exist or is not a directory.");
        System.exit(1);
      }
      if(files.length == 0){
        inputFiles = dir.listFiles(new FileFilter(){
          public boolean accept(File f) {
            return !f.isHidden() && f.isFile();
          }
        });
      }
    }else{
      directory = System.getProperty("user.dir");
    }
    
    if(inputFiles == null){
      inputFiles = new File[files.length];
      for(int i = 0; i < files.length; ++i){
        File f = new File(files[i]);
        boolean exists = false;
        if(!(exists = f.exists())){
          f = new File(directory, files[i]);
          exists = f.exists();
        }
        if(!exists){
          System.out.println("Input file " + files[i] + " does not exist.");
          System.exit(1);
        }
        inputFiles[i] = f;
      }
    }
   
    return inputFiles;
  }