All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ranksys.formats.index.UsersReader Maven / Gradle / Ivy

Go to download

RankSys module, providing utilities for reading and writing into different formats of preference data, recommendations, etc.

The newest version!
/*
 * Copyright (C) 2016 RankSys http://ranksys.org
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.ranksys.formats.index;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.ranksys.formats.parsing.Parser;

/**
 * Reader for lists of users.
 * 
 * @author Saúl Vargas ([email protected])
 */
public class UsersReader {

    /**
     * Reads a list of users from a file.
     *
     * @param  user type
     * @param path path to file
     * @param up user parser
     * @return stream of users
     * @throws IOException when I/O problems
     */
    public static  Stream read(String path, Parser up) throws IOException {
        return read(new FileInputStream(path), up);
    }

    /**
     * Reads a list of users from an input stream.
     *
     * @param  user type
     * @param in input stream to read from
     * @param up user parser
     * @return stream of users
     * @throws IOException when I/O problems
     */
    public static  Stream read(InputStream in, Parser up) throws IOException {
        return Utils.readElemens(in, up);
    }

}