public final class LKFileUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isCompressed(File file)
Deprecated.
Use
CompressionMode or commons-compress facilities instead. |
static Reader |
openInput(File file)
Open a reader with automatic compression and the default character set.
|
static Reader |
openInput(File file,
Charset charset,
CompressionMode compression)
Open a file for input, optionally compressed.
|
static Reader |
openInput(File file,
CompressionMode compression)
Open a file for input with the default charset.
|
static Writer |
openOutput(File file)
Open a reader with automatic compression inference.
|
static Writer |
openOutput(File file,
Charset charset,
CompressionMode compression)
Open a file for input, optionally compressed.
|
static Writer |
openOutput(File file,
CompressionMode compression)
Open a file for output with the default charset.
|
static LongList |
readIdList(File file)
Read a list of long IDs from a file, one per line.
|
static InputStream |
transparentlyDecompress(InputStream stream)
Auto-detect whether a stream needs decompression.
|
@Deprecated public static boolean isCompressed(File file)
CompressionMode
or commons-compress facilities instead.file
- The file to query.true
if the file name ends in “.gz”.public static Reader openInput(File file, Charset charset, CompressionMode compression) throws IOException
file
- The file to open.charset
- The character set to use.compression
- Whether to compress the file.IOException
- if there is an error opening the file.public static Reader openInput(File file, CompressionMode compression) throws IOException
file
- The file to open.compression
- The compression mode.IOException
- if there was an error opening the file.openInput(java.io.File, Charset, CompressionMode)
public static Reader openInput(File file) throws IOException
file
- The file to open.IOException
- if there is an error opening the file.openInput(File, Charset, CompressionMode)
,
CompressionMode.AUTO
,
Charset.defaultCharset()
public static Writer openOutput(File file, Charset charset, CompressionMode compression) throws IOException
file
- The file to open.charset
- The character set to use.compression
- Whether to compress the file.IOException
- if there is an error opening the file.public static Writer openOutput(File file, CompressionMode compression) throws IOException
file
- The file to open.compression
- The compression mode.IOException
- if there was an error opening the file.openInput(java.io.File, Charset, CompressionMode)
public static Writer openOutput(File file) throws IOException
file
- The file to open.IOException
- if there is an error opening the file.public static InputStream transparentlyDecompress(@WillCloseWhenClosed InputStream stream) throws IOException
stream
- The stream to read.stream
, decompressing if needed. It may not be
the same object as stream
, even if no decompression is needed, as the input
stream may be wrapped in a buffered stream for lookahead.IOException
public static LongList readIdList(File file) throws IOException
file
- The file to read.IOException