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

com.talk2object.plum.input.value.DiskFile Maven / Gradle / Ivy

package com.talk2object.plum.input.value;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class DiskFile extends AbstractFile {
	String fileName;

	public DiskFile(String fileName) {
		this.fileName = fileName;

		Path path = Paths.get(fileName);
		try {
			size = Files.size(path);
			contentType = Files.probeContentType(path);
		} catch (IOException e) {

			throw new RuntimeException(e);
		}
	}

	@Override
	public InputStream getInputStream() {
		try {
			FileInputStream in = new FileInputStream(fileName);
			return in;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public String getName() {
		return fileName;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy