public final class Reader extends Object
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier and Type | Method and Description |
---|---|
static CompressionType |
autoDetectCompressionType(String fileName)
Determine the type of compression used in a file.
|
static InputStream |
createInputStream(String fileName)
Construct a InputStream for a compressed data file.
|
static InputStream |
createInputStream(String fileName,
CompressionType compressionType)
Construct a InputStream for a compressed data file.
|
static boolean |
isGZipCompressed(byte[] bytes)
Determine if bytes match the GZip compression signature.
|
public static InputStream createInputStream(String fileName, CompressionType compressionType) throws IOException
fileName
- String; the name of the filecompressionType
- CompressionType; the expected type of the data compression in the fileIOException
- when the file could not be readpublic static InputStream createInputStream(String fileName) throws IOException
fileName
- String; the name of the fileIOException
- when the file can not be opened or readpublic static CompressionType autoDetectCompressionType(String fileName) throws IOException
Derived from
http://stackoverflow.com/questions/4818468/how-to-check-if-inputstream-is-gzipped.
Gzip inflate an inputStream (if it is indeed gzip compressed), otherwise return an InputStream that yields the same data
as the input argument.
fileName
- String; the name of the file to checkIOException
- when errors occur reading the signature bytespublic static boolean isGZipCompressed(byte[] bytes) throws IOException
bytes
- byte[]; at least 2 bytes from the start of the stream to determine compression typeIOException
- if the byte array couldn't be readCopyright © 2014–2019 Delft University of Technology. All rights reserved.