use of org.apache.nifi.minifi.c2.api.util.DelegatingOutputStream in project nifi-minifi by apache.
the class FileSystemWritableConfiguration method getOutputStream.
@Override
public OutputStream getOutputStream() throws ConfigurationProviderException {
try {
Path parent = path.getParent();
Files.createDirectories(parent);
Path tmpPath = cache.resolveChildAndVerifyParent(parent, path.getFileName().toString() + "." + UUID.randomUUID().toString());
return new DelegatingOutputStream(Files.newOutputStream(tmpPath)) {
@Override
public void close() throws IOException {
super.close();
Files.move(tmpPath, path);
}
};
} catch (IOException e) {
throw new ConfigurationProviderException("Unable to open " + path + " for writing.", e);
}
}
Aggregations