Package IOGenerating

Source Code of IOGenerating.InputFromFileGenerator

package IOGenerating;

import IOGenerating.Exceptions.InputGeneratingException;
import Program.Program;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;

/**
*
* @author partizanka
*/
public class InputFromFileGenerator extends InputGenerator {

    private Program program;

    /**
     *
     * @param program
     */
    public InputFromFileGenerator(Program program) {
        this.program = program;
    }

    /**
     *
     * @param testNumber
     * @return
     * @throws InputGeneratingException
     */
    public Reader getReader(int testNumber) throws InputGeneratingException {
        Reader reader = null;
        try {
            reader = new FileReader(program.problem.getPathToTests() + "/" + program.problem.in[testNumber]);
        } catch (FileNotFoundException e) {
            throw new InputGeneratingException("Test input not found: " + e);
        }
        return reader;
    }
}
TOP

Related Classes of IOGenerating.InputFromFileGenerator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.