com.danielsomerfield.util.io.FilePathOutputStreamFactory.groovy Maven / Gradle / Ivy
package com.danielsomerfield.util.io
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class FilePathOutputStreamFactory implements OutputStreamFactory {
private final String path;
private Logger logger = LoggerFactory.getLogger(getClass())
public FilePathOutputStreamFactory(final String path) {
this.path = path;
new File(path).getParentFile().mkdirs()
}
@Override
public OutputStream getOutputStream() {
logger.debug("getOutputStream: path = $path")
return new FileOutputStream(path)
}
}