code: public static int getLinkCount(File fileName) throws IOException {
      if (fileName == null) {
        throw new IOException(
            "invalid argument to getLinkCount: file name is null");
      }
      if (!fileName.exists()) {
        throw new FileNotFoundException(fileName + " not found.");
      }
  
      // construct and execute shell command
      String[] cmd = getHardLinkCommand.linkCount(fileName);
      String inpMsg = null;
      String errMsg = null;
      int exitValue = -1;
      BufferedReader in = null;
      BufferedReader err = null;
  
      Process process = Runtime.getRuntime().exec(cmd);
      try {
        exitValue = process.waitFor();
        in = new BufferedReader(new InputStreamReader(
                                    process.getInputStream()));
        inpMsg = in.readLine();
        err = new BufferedReader(new InputStreamReader(
                                     process.getErrorStream()));
        errMsg = err.readLine();
        if (inpMsg == null || exitValue != 0) {
          throw createIOException(fileName, inpMsg, errMsg, exitValue, null);
        }
        if (osType == OSType.OS_TYPE_SOLARIS) {
          String[] result = inpMsg.split("\\s+");
          return Integer.parseInt(result[1]);
        } else {
          return Integer.parseInt(inpMsg);
        }
      } catch (NumberFormatException e) {
        throw createIOException(fileName, inpMsg, errMsg, exitValue, e);
      } catch (InterruptedException e) {
        throw createIOException(fileName, inpMsg, errMsg, exitValue, e);
      } finally {
        process.destroy();
        if (in != null) in.close();
        if (err != null) err.close();
      }
    }
docs: Retrieves the number of links to the specified file.