code: long parseMemoryLine(final String line) {
      final int idx1 = line.indexOf(":");
      final int idx2 = line.lastIndexOf("kB");
      final String sizeString = line.substring(idx1 + 1, idx2 - 1).trim();
      try {
        return Long.parseLong(sizeString);
      } catch (final NumberFormatException e) {
        final String err = "Failed to parse the meminfo file. Line: " + line;
        logger.error(err);
        return 0;
      }
    }
docs: Example file: $ cat /proc/meminfo MemTotal:       65894008 kB MemFree:        59400536 kB
  Buffers:          409348 kB Cached:          4290236 kB SwapCached:            0 kB
  
  Make the method package private to make unit testing easier. Otherwise it can be made private.
  
  @param line the text for a memory usage statistics we are interested in
  @return size of the memory. unit kB. 0 if there is an error.