private static LinuxRelease parseLinuxOsReleaseFile(File file) {
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8"));

            String id = null;
            String version = null;
            final Set<String> likeSet = new LinkedHashSet<String>();
            String line;
            while((line = reader.readLine()) != null) {
                // Parse the ID line.
                if (line.startsWith(LINUX_ID_PREFIX)) {
                    // Set the ID for this version.
                    id = normalizeOsReleaseValue(line.substring(LINUX_ID_PREFIX.length()));

                    // Also add the ID to the "like" set.
                    likeSet.add(id);
                    continue;
                }

                // Parse the VERSION_ID line.
                if (line.startsWith(LINUX_VERSION_ID_PREFIX)) {
                    // Set the ID for this version.
                    version = normalizeOsReleaseValue(line.substring(LINUX_VERSION_ID_PREFIX.length()));
                    continue;
                }

                // Parse the ID_LIKE line.
                if (line.startsWith(LINUX_ID_LIKE_PREFIX)) {
                    line = normalizeOsReleaseValue(line.substring(LINUX_ID_LIKE_PREFIX.length()));

                    // Split the line on any whitespace.
                    final String[] parts =  line.split("\\s+");
                    Collections.addAll(likeSet, parts);
                }
            }

            if (id != null) {
                return new LinuxRelease(id, version, likeSet);
            }
        } catch (IOException ignored) {
            // Just absorb. Don't treat failure to read /etc/os-release as an error.
        } finally {
            closeQuietly(reader);
        }
        return null;
    }
private static LinuxRelease parseLinuxOsReleaseFile ( File file ) { BufferedReader reader = null ; try { reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) , "utf-8" ) ) ; String id = null ; String version = null ; final Set < String > likeSet = new LinkedHashSet < String > ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . startsWith ( LINUX_ID_PREFIX ) ) { id = normalizeOsReleaseValue ( line . substring ( LINUX_ID_PREFIX . length ( ) ) ) ; likeSet . add ( id ) ; continue ; } if ( line . startsWith ( LINUX_VERSION_ID_PREFIX ) ) { version = normalizeOsReleaseValue ( line . substring ( LINUX_VERSION_ID_PREFIX . length ( ) ) ) ; continue ; } if ( line . startsWith ( LINUX_ID_LIKE_PREFIX ) ) { line = normalizeOsReleaseValue ( line . substring ( LINUX_ID_LIKE_PREFIX . length ( ) ) ) ; final String [ ] parts = line . split ( "\\s+" ) ; Collections . addAll ( likeSet , parts ) ; } } if ( id != null ) { return new LinuxRelease ( id , version , likeSet ) ; } } catch ( IOException ignored ) { } finally { closeQuietly ( reader ) ; } return null ; }
Parses a file in the format of {@code /etc/os-release} and return a {@link LinuxRelease}
based on the {@code ID}, {@code ID_LIKE}, and {@code VERSION_ID} entries.