package org.javafxdata.datasources.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * 
 * Implementation of DataSourceReader for (local) filesystems.
 * Instances of this class can be created and passed in the 
 * constructor of a protocol implementations in the
 * org.javafxdata.datasources.io package.
 *
 * @author johan
 */
public class FileSource implements DataSourceReader {
    
    private InputStream is;
    
    /**
     * Create a FileSource based on an existing file.
     * 
     * @param filename the filename
     * @throws FileNotFoundException 
     */
    public FileSource (String filename) throws FileNotFoundException {
        this.is = new FileInputStream (filename);
    }
    
    public FileSource (File f) throws FileNotFoundException {
        this.is = new FileInputStream(f);
    }
    
    public FileSource (InputStream is) {
        this.is = is;
    }

    @Override
    public InputStream getInputStream() {
        return this.is;
    }

}
