private static void getTargetPathsFromSymlinksDirs(
      Configuration conf, Path[] symlinksDirs,
      List<Path> targetPaths, List<Path> symlinkPaths) throws IOException {
    for (Path symlinkDir : symlinksDirs) {
      FileSystem fileSystem = symlinkDir.getFileSystem(conf);
      FileStatus[] symlinks = fileSystem.listStatus(symlinkDir, FileUtils.HIDDEN_FILES_PATH_FILTER);

      // Read paths from each symlink file.
      for (FileStatus symlink : symlinks) {
        BufferedReader reader = null;
        try {
          reader = new BufferedReader(
              new InputStreamReader(
                  fileSystem.open(symlink.getPath())));
          String line;
          while ((line = reader.readLine()) != null) {
            targetPaths.add(new Path(line));
            symlinkPaths.add(symlink.getPath());
          }
        } finally {
          org.apache.hadoop.io.IOUtils.closeStream(reader);
        }
      }
    }
  }
Given list of directories containing symlink files, read all target
paths from symlink files and return as targetPaths list. And for each
targetPaths[i], symlinkPaths[i] will be the path to the symlink file
containing the target path.
ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java