class Files2 {

    @Nullable
    public static File getRelativeFile(@NonNull File[] paths, @NonNull File file) {
        if (!file.isAbsolute()) {
            return file;
        }
        String path = file.getAbsolutePath();
        for (File parent : paths) {
            String parentPath = parent.getAbsolutePath() + File.separator;
            if (path.startsWith(parentPath)) {
                return new File(path.substring(parentPath.length()));
            }
        }
        // absolute file outside paths
        return null;
    }

    private  Files2();

}