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

com.mozafaq.extmergesort.FileSystemStreamReader Maven / Gradle / Ivy

There is a newer version: 2.0.4.RELEASE
Show newest version
package com.mozafaq.extmergesort;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author Mozaffar Afaque
 */
public class FileSystemStreamReader implements StreamReader {
    InputStream inputStream = null;
    private String location;

    public FileSystemStreamReader(String location) {
        this.location = location;
    }

    @Override
    public InputStream open() throws IOException {
        if (inputStream != null) {
            throw new IllegalStateException("Stream is already open!");
        }
        inputStream = new FileInputStream(location);
        return inputStream;
    }

    @Override
    public void close() throws IOException{
        inputStream.close();
    }

    @Override
    public InputStream get() {
        return inputStream;
    }

    @Override
    public String getFullPath() {
        return location;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy