public static UnixMountInfo parseMountInfo(String line) {
    // Example mount lines:
    // ramfs on /mnt/ramdisk type ramfs (rw,relatime,size=1gb)
    // map -hosts on /net (autofs, nosuid, automounted, nobrowse)
    UnixMountInfo.Builder builder = new UnixMountInfo.Builder();

    // First get and remove the mount type if it's provided.
    Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line);
    String lineWithoutType;
    if (matcher.matches()) {
      String match = matcher.group(1);
      builder.setFsType(match.replace("type", "").trim());
      lineWithoutType = line.replace(match, "");
    } else {
      lineWithoutType = line;
    }
    // Now parse the rest
    matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType);
    if (!matcher.matches()) {
      LOG.debug("Unable to parse output of 'mount': {}", line);
      return builder.build();
    }
    builder.setDeviceSpec(matcher.group(1));
    builder.setMountPoint(matcher.group(2));
    builder.setOptions(parseUnixMountOptions(matcher.group(3)));
    return builder.build();
  }
public static UnixMountInfo parseMountInfo ( String line ) { UnixMountInfo . Builder builder = new UnixMountInfo . Builder ( ) ; Matcher matcher = Pattern . compile ( ".* (type \\w+ ).*" ) . matcher ( line ) ; String lineWithoutType ; if ( matcher . matches ( ) ) { String match = matcher . group ( 1 ) ; builder . setFsType ( match . replace ( "type" , "" ) . trim ( ) ) ; lineWithoutType = line . replace ( match , "" ) ; } else { lineWithoutType = line ; } matcher = Pattern . compile ( "(.*) on (.*) \\((.*)\\)" ) . matcher ( lineWithoutType ) ; if ( ! matcher . matches ( ) ) { LOG . debug ( "Unable to parse output of 'mount': {}" , line ) ; return builder . build ( ) ; } builder . setDeviceSpec ( matcher . group ( 1 ) ) ; builder . setMountPoint ( matcher . group ( 2 ) ) ; builder . setOptions ( parseUnixMountOptions ( matcher . group ( 3 ) ) ) ; return builder . build ( ) ; }
@param line the line to parse
@return the parsed {@link UnixMountInfo}