public class Io extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ASCII_CODEC_NAME |
static String |
infraRedHostName
This is the host name associated with the infra-red port.
|
static String |
ISO_8859_1_CODEC_NAME |
static String |
JAVA_UTF8_CODEC_NAME |
static int |
SAVE_IN_FILE
Option for saveConfigInfo().
|
static int |
SAVE_IN_FILE_OR_REGISTRY
Option for saveConfigInfo().
|
static int |
SAVE_IN_REGISTRY
Option for saveConfigInfo().
|
static String |
STANDARD_UTF8_CODEC_NAME |
Constructor and Description |
---|
Io() |
Modifier and Type | Method and Description |
---|---|
static void |
addCodec(TextCodec codec,
String names)
Add a codec with the specified names.
|
static int |
deflate(byte[] src,
int offset,
int length,
ByteArray destination)
Using the most efficient method possible, compress using deflation a single block
of bytes producing a single block of bytes which are appended to a destination
ByteArray.
|
static int |
deflate(Deflater def,
byte[] src,
int offset,
int length,
ByteArray destination)
Using the most efficient method possible, compress using deflation a single block
of bytes producing a single block of bytes which are appended to a destination
ByteArray.
|
static int |
deflate(Deflater def,
int[] src,
int offset,
int length,
ByteArray destination)
Using the most efficient method possible, compress using deflation a single block
of ints producing a single block of bytes which are appended to a destination
ByteArray.
|
static String |
fileLengthDisplay(long len)
Convert a file length to K or M notation.
|
static BufferedReader |
getBufferedReader(File f) |
static BufferedReader |
getBufferedReader(File f,
TextCodec codec)
Get a BufferedReader using an EncodedStreamReader with a specific codec that
reads from an InputStream from the specified file.
|
static BufferedReader |
getBufferedReader(InputStream in,
String defCharSet) |
static TextCodec |
getCodec(String name,
boolean useDefaultIfNotFound)
Get a TextCodec with the specified name.
|
static TextCodec |
getCodec(String name,
TextCodec defaultIfNotFound)
Get a TextCodec with the specified name.
|
static File |
getConfigFile(String keyName)
Given a configuration name, determine the file that
it would be stored in if saveConfigInfo() was used with the SAVE_IN_FILE_xxx option.
|
static File |
getConfigFile(String keyName,
boolean resetConfig)
Given a configuration name, find and optionally reset the file name that
it would be stored in if saveConfigInfo() was used with the SAVE_IN_FILE_xxx option.
|
static File |
getConfigFile(String keyName,
boolean resetConfig,
String userHomeDirectory)
Given a configuration name, find and optionally reset the file name that
it would be stored in if saveConfigInfo() was used with the SAVE_IN_FILE_xxx option.
|
static String |
getConfigInfo(String name) |
static String |
getConfigInfo(String name,
String userHomeDirectory) |
static TextCodec |
getDefaultCodec()
Return the platform's default codec.
|
static String |
getDefaultCodecName()
Return the platform's default TextCodec name.
|
static PrintWriter |
getPrintWriter(File f) |
static PrintWriter |
getPrintWriter(File f,
boolean append) |
static Reader |
getReader(InputStream in,
String defCharSet) |
static Vector |
getStringList(String keyName)
Read a Vector containing a list of string using getConfigInfo.
|
static int |
inflate(byte[] src,
int offset,
int length,
ByteArray destination)
Using the most efficient method possible, decompress using inflate a single block
of bytes producing a single block of bytes which are appended to a destination
ByteArray.
|
static int |
inflate(Inflater inf,
byte[] src,
int offset,
int length,
ByteArray destination)
Using the most efficient method possible, decompress using inflation a single block
of bytes producing a single block of bytes which are appended to a destination
ByteArray.
|
static int |
inflate(Inflater inf,
byte[] src,
int offset,
int length,
IntArray destination)
Using the most efficient method possible, decompress using inflation a single block
of bytes producing a single block of ints which are appended to a destination
IntArray.
|
static InputStream |
newFileInputStream(String name) |
static OutputStream |
newFileOutputStream(String name,
boolean append) |
static RandomStream |
newFileRandomStream(String name,
String mode) |
static ByteArray |
processAll(DataProcessor dp,
byte[] source) |
static ByteArray |
processAll(DataProcessor dp,
byte[] source,
int offset,
int length) |
static ByteArray |
processAll(DataProcessor dp,
byte[] source,
int offset,
int length,
ByteArray dest) |
static void |
saveConfigInfo(String data,
String name,
int options) |
static void |
saveConfigInfo(String data,
String name,
int options,
String userHomeDirectory) |
static void |
saveRemoteConfigInfo(String data,
String name,
String destinationDirectory) |
static void |
saveStringList(Vector text,
String keyName,
int saveOptions)
Save a Vector containing a list of strings using saveConfigInfo.
|
static void |
setDefaultCodec(TextCodec tc,
String name)
Set the platform's default TextCodec.
|
static IBlockInput |
toBlockInput(InputStream in) |
static IBlockOutput |
toBlockOutput(OutputStream out) |
public static final String infraRedHostName
public static final String JAVA_UTF8_CODEC_NAME
public static final String STANDARD_UTF8_CODEC_NAME
public static final String ASCII_CODEC_NAME
public static final String ISO_8859_1_CODEC_NAME
public static final int SAVE_IN_REGISTRY
public static final int SAVE_IN_FILE
public static final int SAVE_IN_FILE_OR_REGISTRY
public static void addCodec(TextCodec codec, String names)
codec
- The TextCodec.names
- A comma separated list of names for the codec.public static TextCodec getCodec(String name, boolean useDefaultIfNotFound) throws UnsupportedEncodingException
name
- The name of the codec.useDefaultIfNotFound
- if this is true then the default codec will be returned
if the codec with the specified name was not found. Otherwise an UnsupportedEncodingException
will be thrown.UnsupportedEncodingException
- if no codec was found.public static TextCodec getCodec(String name, TextCodec defaultIfNotFound) throws UnsupportedEncodingException
name
- The name of the codec.defaultIfNotFound
- A codec to return
if the codec with the specified name was not found. If this is null and
a codec is not found then an UnsupportedEncodingException
will be thrown.UnsupportedEncodingException
- if no codec was found.public static String getDefaultCodecName()
public static TextCodec getDefaultCodec()
public static void setDefaultCodec(TextCodec tc, String name)
public static ByteArray processAll(DataProcessor dp, byte[] source)
public static ByteArray processAll(DataProcessor dp, byte[] source, int offset, int length)
public static ByteArray processAll(DataProcessor dp, byte[] source, int offset, int length, ByteArray dest) throws IOException
IOException
public static int deflate(byte[] src, int offset, int length, ByteArray destination) throws IOException
src
- the source of the bytes to compress.offset
- the start of the bytes to compress.length
- the number of bytes to compress.destination
- an destination ByteArray which must not be null.IOException
public static int deflate(Deflater def, byte[] src, int offset, int length, ByteArray destination) throws IOException
def
- a non-null Deflater to use for deflation.src
- the source of the bytes to compress.offset
- the start of the bytes to compress.length
- the number of bytes to compress.destination
- an destination ByteArray which must not be null.IOException
public static int deflate(Deflater def, int[] src, int offset, int length, ByteArray destination) throws IOException
def
- a non-null Deflater to use for deflation.src
- the source of the ints to compress.offset
- the start of the ints to compress.length
- the number of ints to compress.destination
- an destination ByteArray which must not be null.IOException
public static int inflate(byte[] src, int offset, int length, ByteArray destination) throws IOException
src
- the source of the bytes to decompress.offset
- the start of the bytes to decompress.length
- the number of bytes to decompress.destination
- an destination ByteArray which must not be null.IOException
public static int inflate(Inflater inf, byte[] src, int offset, int length, ByteArray destination) throws IOException
def
- a non-null Inflater to use for inflation.src
- the source of the bytes to decompress.offset
- the start of the bytes to decompress.length
- the number of bytes to decompress.destination
- an destination ByteArray which must not be null.IOException
public static int inflate(Inflater inf, byte[] src, int offset, int length, IntArray destination) throws IOException
def
- a non-null inflater to use for inflation.src
- the source of the bytes to decompress.offset
- the start of the bytes to decompress.length
- the number of bytes to decompress.destination
- an destination IntArray which must not be null.IOException
public static String fileLengthDisplay(long len)
len
- the length to convert.public static File getConfigFile(String keyName)
name
- the name of the configuration.public static File getConfigFile(String keyName, boolean resetConfig)
name
- the name of the configuration.resetConfig
- if this is true then the old config file name is ignored
(the one stored in the registry) and a new one is generated and saved.public static File getConfigFile(String keyName, boolean resetConfig, String userHomeDirectory)
name
- the name of the configuration.resetConfig
- if this is true then the old config file name is ignored
(the one stored in the registry) and a new one is generated and saved.the
- user home directory name (which will be used in Unix/Linux platforms)
or null to let the system determine that if necessary using
Registry.getUserHomeDirectory().public static String getConfigInfo(String name) throws IOException
IOException
public static String getConfigInfo(String name, String userHomeDirectory) throws IOException
IOException
public static void saveConfigInfo(String data, String name, int options) throws IOException
IOException
public static void saveRemoteConfigInfo(String data, String name, String destinationDirectory) throws IOException
IOException
public static void saveConfigInfo(String data, String name, int options, String userHomeDirectory) throws IOException
IOException
public static void saveStringList(Vector text, String keyName, int saveOptions) throws IOException
text
- The list of strings to save.keyName
- The key name to use. This will be passed to saveConfigInfo().saveOptions
- one of the SAVE_IN options.IOException
- If there was an error saving the information.public static Vector getStringList(String keyName) throws IOException
keyName
- The name of the key to save under.IOException
- If there was an error reading the information.public static BufferedReader getBufferedReader(File f, TextCodec codec) throws IOException
f
- the file to read.codec
- the codec to use.IOException
- on an error opening the file.public static BufferedReader getBufferedReader(File f) throws IOException
IOException
public static Reader getReader(InputStream in, String defCharSet) throws IOException
IOException
public static BufferedReader getBufferedReader(InputStream in, String defCharSet) throws IOException
IOException
public static PrintWriter getPrintWriter(File f, boolean append) throws IOException
IOException
public static PrintWriter getPrintWriter(File f) throws IOException
IOException
public static OutputStream newFileOutputStream(String name, boolean append) throws IOException
IOException
public static InputStream newFileInputStream(String name) throws IOException
IOException
public static RandomStream newFileRandomStream(String name, String mode) throws IOException
IOException
public static IBlockOutput toBlockOutput(OutputStream out)
public static IBlockInput toBlockInput(InputStream in)