Package gov.usgs.earthquake.product.io
Class IOUtil
- java.lang.Object
-
- gov.usgs.earthquake.product.io.IOUtil
-
public class IOUtil extends java.lang.Object
Class with main method for converting from one product format to another.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BINARY_FORMAT
Binary formatstatic java.lang.String
DIRECTORY_FORMAT
Directory formatstatic java.lang.String
INFILE_ARGUMENT
Argument for input filestatic java.lang.String
INFORMAT_ARGUMENT
Argument for input formatstatic java.lang.String
OUTFILE_ARGUMENT
Argument for output filestatic java.lang.String
OUTFORMAT_ARGUMENT
Argument for output formatstatic java.lang.String
XML_FORMAT
XML formatstatic java.lang.String
ZIP_FORMAT
Zip format
-
Constructor Summary
Constructors Constructor Description IOUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.BufferedInputStream
autoDetectDeflate(java.io.InputStream in)
Auto detect an optionally deflated stream.static ProductSource
autoDetectProductSource(java.io.InputStream in)
Auto detect an Xml or Binary product source, that is optionally deflated.static ProductHandler
getProductHandler(java.lang.String outformat, java.io.File outfile)
Returns a ProductHandler based on the output formatstatic ProductSource
getProductSource(java.lang.String informat, java.io.File infile)
Returns a product source based on input formatstatic void
main(java.lang.String[] args)
Access into IOUtil Takes arguments, gets product source and handler Streams source to handlerstatic void
printUsage()
CLI usage
-
-
-
Field Detail
-
INFILE_ARGUMENT
public static final java.lang.String INFILE_ARGUMENT
Argument for input file- See Also:
- Constant Field Values
-
INFORMAT_ARGUMENT
public static final java.lang.String INFORMAT_ARGUMENT
Argument for input format- See Also:
- Constant Field Values
-
OUTFILE_ARGUMENT
public static final java.lang.String OUTFILE_ARGUMENT
Argument for output file- See Also:
- Constant Field Values
-
OUTFORMAT_ARGUMENT
public static final java.lang.String OUTFORMAT_ARGUMENT
Argument for output format- See Also:
- Constant Field Values
-
ZIP_FORMAT
public static final java.lang.String ZIP_FORMAT
Zip format- See Also:
- Constant Field Values
-
XML_FORMAT
public static final java.lang.String XML_FORMAT
XML format- See Also:
- Constant Field Values
-
DIRECTORY_FORMAT
public static final java.lang.String DIRECTORY_FORMAT
Directory format- See Also:
- Constant Field Values
-
BINARY_FORMAT
public static final java.lang.String BINARY_FORMAT
Binary format- See Also:
- Constant Field Values
-
-
Method Detail
-
getProductHandler
public static ProductHandler getProductHandler(java.lang.String outformat, java.io.File outfile) throws java.io.IOException
Returns a ProductHandler based on the output format- Parameters:
outformat
- Output formatoutfile
- Output file- Returns:
- a Product Handler
- Throws:
java.io.IOException
- if IO error occurs
-
getProductSource
public static ProductSource getProductSource(java.lang.String informat, java.io.File infile) throws java.lang.IllegalArgumentException, java.io.IOException
Returns a product source based on input format- Parameters:
informat
- input file formatinfile
- input file- Returns:
- a Productsource
- Throws:
java.lang.IllegalArgumentException
- if informat argument errorjava.io.IOException
- if error occurs
-
autoDetectProductSource
public static ProductSource autoDetectProductSource(java.io.InputStream in) throws java.io.IOException
Auto detect an Xml or Binary product source, that is optionally deflated.- Parameters:
in
- input stream containing optionally deflated xml or binary product stream.- Returns:
- ProductSource object.
- Throws:
java.io.IOException
- if neither binary or xml product source is in stream.
-
autoDetectDeflate
public static java.io.BufferedInputStream autoDetectDeflate(java.io.InputStream in) throws java.io.IOException
Auto detect an optionally deflated stream.- Parameters:
in
- input stream containing optionally deflated xml or binary product stream.- Returns:
- ProductSource object.
- Throws:
java.io.IOException
- if neither binary or xml product source is in stream.
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Access into IOUtil Takes arguments, gets product source and handler Streams source to handler- Parameters:
args
- CLI args for infile, informat, outfile, outformat- Throws:
java.lang.Exception
- if error occurs
-
printUsage
public static void printUsage()
CLI usage
-
-