PySkeletonHeader (@NotNull File file) { try (LineNumberReader reader = new LineNumberReader(new FileReader(file, StandardCharsets.UTF_8))) { String line = null; // Read 3 lines, skip first 2: encoding, module name for (int i = 0; i < 3; i++) { line = reader.readLine(); if (line == null) { return null; } } // Try the old whitespace-unsafe header format v1 first final Matcher v1Matcher = VERSION_LINE_V1.matcher(line); if (v1Matcher.matches()) { return new PySkeletonHeader(v1Matcher.group(1), fromVersionString(v1Matcher.group(2))); } final Matcher fromMatcher = FROM_LINE_V2.matcher(line); if (fromMatcher.matches()) { final String binaryFile = fromMatcher.group(1); line = reader.readLine(); if (line != null) { final Matcher byMatcher = BY_LINE_V2.matcher(line); if (byMatcher.matches()) { final int version = fromVersionString(byMatcher.group(1)); return new PySkeletonHeader(binaryFile, version); } } } } catch (IOException ignored) { } return null; }