All Packages Class Hierarchy This Package Previous Next Index
Class hplb.misc.ByteArray
java.lang.Object
|
+----hplb.misc.ByteArray
- public class ByteArray
- extends Object
This class is a container for algorithms working on byte arrays - some
of the algorithms are analogous to those in java.lang.String.
- Author:
- Anders Kristensen
-
ByteArray()
-
-
cpybytes(InputStream, OutputStream)
- Copies data from the specified input stream to the output stream
until end of file is met.
-
cpybytes(InputStream, OutputStream, int)
- Copies data from the specified input stream to the output stream
until n bytes has been copied or end of file is met.
-
findBytes(byte[], int, int, byte[])
- Find byte pattern ptrn in buffer buf.
-
getBytes(String)
- Returns copy of characters in s as a new byte array.
-
getContent(URL)
- Return contents of a WWW resource identified by a URL.
-
indexOf(byte[], int)
- Returns the index within this String of the first occurrence of the
specified character or -1 if the character is not found.
-
indexOf(byte[], int, int, int)
- Returns the index within this String of the first occurrence of the
specified character, starting the search at fromIndex.
-
indexOf(byte[], String)
- Returns the index of the first occurrence of s in the specified
buffer or -1 if this is not found.
-
indexOf(byte[], String, int)
- Returns the index of the first occurrence of s in the specified
buffer.
-
isSpace(int)
-
-
loadFromFile(File)
- Returns contents of file file as byte array.
-
loadFromFile(String)
- Returns contents of file as byte array.
-
readAll(InputStream)
- Read all input from an InputStream and return as a byte array.
-
readn(InputStream, int)
- Reads n bytes from the specified input stream.
-
skipSpaces(byte[], int, int)
-
ByteArray
public ByteArray()
getBytes
public static final byte[] getBytes(String s)
- Returns copy of characters in s as a new byte array.
loadFromFile
public static byte[] loadFromFile(String filename) throws IOException
- Returns contents of file as byte array.
loadFromFile
public static byte[] loadFromFile(File file) throws IOException
- Returns contents of file file as byte array.
readn
public static byte[] readn(InputStream in,
int n) throws IOException
- Reads n bytes from the specified input stream. It will return
fewer bytes if fewer bytes are available on the stream.
Hence the application should check the resulting arrays length.
getContent
public static byte[] getContent(URL url) throws IOException
- Return contents of a WWW resource identified by a URL.
- Parameters:
- url - the resource to retrieve
- Returns:
- the resource contents as a byte array
readAll
public static byte[] readAll(InputStream in) throws IOException
- Read all input from an InputStream and return as a byte array.
This method will not return before the end of the stream is reached.
- Returns:
- contents of the stream
cpybytes
public static int cpybytes(InputStream in,
OutputStream out) throws IOException
- Copies data from the specified input stream to the output stream
until end of file is met.
- Returns:
- the total number of bytes written to the output stream
cpybytes
public static int cpybytes(InputStream in,
OutputStream out,
int n) throws IOException
- Copies data from the specified input stream to the output stream
until n bytes has been copied or end of file is met.
- Returns:
- the total number of bytes written to the output stream
indexOf
public static final int indexOf(byte buf[],
int ch)
- Returns the index within this String of the first occurrence of the
specified character or -1 if the character is not found.
- Parameters:
- s - buf the buffer to search
- s - ch the character to search for
indexOf
public static final int indexOf(byte buf[],
int ch,
int fromIndex,
int toIndex)
- Returns the index within this String of the first occurrence of the
specified character, starting the search at fromIndex. This method
returns -1 if the character is not found.
- Parameters:
- s - buf the buffer to search
- s - ch the character to search for
- s - fromIndex the index to start the search from
- s - toIndex the highest possible index returned plus 1
indexOf
public static final int indexOf(byte buf[],
String s)
- Returns the index of the first occurrence of s in the specified
buffer or -1 if this is not found.
indexOf
public static final int indexOf(byte buf[],
String s,
int fromIndex)
- Returns the index of the first occurrence of s in the specified
buffer. The search starts from fromIndex. This method returns -1
if the index is not found.
isSpace
public static final boolean isSpace(int ch)
skipSpaces
public static final int skipSpaces(byte buf[],
int fromIndex,
int toIndex)
findBytes
public static final int findBytes(byte buf[],
int off,
int len,
byte ptrn[])
- Find byte pattern ptrn in buffer buf.
- Returns:
- index of first occurrence of ptrn in buf, -1 if no occurence
All Packages Class Hierarchy This Package Previous Next Index