Package com.powsybl.commons.datasource
Class FileDataSource
- java.lang.Object
-
- com.powsybl.commons.datasource.FileDataSource
-
- All Implemented Interfaces:
DataSource
,ReadOnlyDataSource
- Direct Known Subclasses:
Bzip2FileDataSource
,GzFileDataSource
,XZFileDataSource
,ZstdFileDataSource
public class FileDataSource extends Object implements DataSource
- Author:
- Geoffroy Jamgotchian
-
-
Constructor Summary
Constructors Constructor Description FileDataSource(Path directory, String baseName)
FileDataSource(Path directory, String baseName, DataSourceObserver observer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
exists(String fileName)
boolean
exists(String suffix, String ext)
String
getBaseName()
protected InputStream
getCompressedInputStream(InputStream is)
protected OutputStream
getCompressedOutputStream(OutputStream os)
protected String
getCompressionExt()
Set<String>
listNames(String regex)
InputStream
newInputStream(String fileName)
InputStream
newInputStream(String suffix, String ext)
OutputStream
newOutputStream(String fileName, boolean append)
OutputStream
newOutputStream(String suffix, String ext, boolean append)
-
-
-
Constructor Detail
-
FileDataSource
public FileDataSource(Path directory, String baseName, DataSourceObserver observer)
-
-
Method Detail
-
getBaseName
public String getBaseName()
- Specified by:
getBaseName
in interfaceReadOnlyDataSource
-
getCompressionExt
protected String getCompressionExt()
-
getCompressedInputStream
protected InputStream getCompressedInputStream(InputStream is) throws IOException
- Throws:
IOException
-
getCompressedOutputStream
protected OutputStream getCompressedOutputStream(OutputStream os) throws IOException
- Throws:
IOException
-
newOutputStream
public OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException
- Specified by:
newOutputStream
in interfaceDataSource
- Throws:
IOException
-
newOutputStream
public OutputStream newOutputStream(String fileName, boolean append) throws IOException
- Specified by:
newOutputStream
in interfaceDataSource
- Throws:
IOException
-
exists
public boolean exists(String suffix, String ext) throws IOException
- Specified by:
exists
in interfaceReadOnlyDataSource
- Throws:
IOException
-
exists
public boolean exists(String fileName) throws IOException
- Specified by:
exists
in interfaceReadOnlyDataSource
- Throws:
IOException
-
newInputStream
public InputStream newInputStream(String suffix, String ext) throws IOException
- Specified by:
newInputStream
in interfaceReadOnlyDataSource
- Throws:
IOException
-
newInputStream
public InputStream newInputStream(String fileName) throws IOException
- Specified by:
newInputStream
in interfaceReadOnlyDataSource
- Throws:
IOException
-
listNames
public Set<String> listNames(String regex) throws IOException
- Specified by:
listNames
in interfaceReadOnlyDataSource
- Throws:
IOException
-
-