-
- All Known Subinterfaces:
I2C,I2CRegister,Serial,Spi
- All Known Implementing Classes:
I2CBase,SerialBase,SpiBase
public interface IODataWriterData Writer Interface for Pi4J Data Communications- Version:
- $Id: $Id
- Author:
- Robert Savage Based on previous contributions from: Daniel Sendula, RasPelikan
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default OutputStreamgetOutputStream()Get an output stream to write data todefault OutputStreamout()Get an output stream to write data tointwrite(byte b)Write a single raw byte value.default intwrite(byte... data)Write an array of byte values (all bytes in array).default intwrite(byte[]... data)Write multiple byte arrays.default intwrite(byte[] data, int length)Write an array of byte values starting with the first byte in the array up to the provided length.intwrite(byte[] data, int offset, int length)Write an array of byte values with given offset (starting position) and length in the provided data array.default intwrite(char... data)Writes an ASCII based character array (1 or more chars).default intwrite(char[] data, int length)Writes an ASCII based character array (1 or more chars) with a given length starting from the 0 index position.default intwrite(char[] data, int offset, int length)Writes an ASCII based character array (1 or more chars) with a given offset and length.default intwrite(int b)Write a single raw byte value.default intwrite(InputStream stream)Write a stream of data (all bytes available in input stream).default intwrite(InputStream... stream)Write multiple streams of data (all bytes available in each input stream).default intwrite(InputStream stream, int length)Write a stream of stream of data up to the length (number of bytes) specified.default intwrite(CharSequence data)Writes an ASCII data string/character sequence.default intwrite(CharSequence... data)Writes multiple ASCII data strings/character sequences.default intwrite(ByteBuffer buffer)Write a buffer of byte values (all bytes in buffer).default intwrite(ByteBuffer... buffer)Write multiple byte buffers of data.default intwrite(ByteBuffer buffer, int length)Write a buffer of byte values starting with the first byte in the array up to the provided length.default intwrite(ByteBuffer buffer, int offset, int length)Write a buffer of byte values with given offset (starting position) and length in the provided data buffer.default intwrite(CharBuffer buffer)Writes an ASCII based character buffer.default intwrite(CharBuffer... buffer)Writes multiple ASCII based character buffers.default intwrite(CharBuffer buffer, int length)Writes an ASCII based character buffer starting at first index to a given length.default intwrite(CharBuffer buffer, int offset, int length)Writes an ASCII based character buffer with a given offset and length.default intwrite(Charset charset, char... data)Writes a character array (1 or more chars).default intwrite(Charset charset, char[] data, int length)Writes a character based array starting at the first index with a given length.default intwrite(Charset charset, char[] data, int offset, int length)Writes a character based array with a given offset and length.default intwrite(Charset charset, CharSequence data)Writes a data string with specified character set (encoding).default intwrite(Charset charset, CharSequence... data)Writes a data string with specified character set (encoding).default intwrite(Charset charset, CharBuffer buffer)Writes character buffer using a specified character set to encode the chars into bytes.default intwrite(Charset charset, CharBuffer... buffer)Writes multiple character buffers using a specified character set to encode the chars into bytes.default intwrite(Charset charset, CharBuffer buffer, int length)Writes a character buffer starting at first index to a given length using a specified character set to encode the chars into bytes.default intwrite(Charset charset, CharBuffer buffer, int offset, int length)Writes a character buffer with a given offset and length using a specified character set to encode the chars into bytes.default intwrite(Charset charset, Collection<char[]> data)Write a collection of character arrays.default intwrite(Charset charset, Collection<CharSequence>... data)Write a collection of ASCII character sequences with specified character set (encoding).default intwrite(Collection<byte[]> data)Write a collection of byte arrays.default intwrite(Collection<CharSequence>... data)Write a collection of ASCII character sequences.
-
-
-
Method Detail
-
write
int write(byte b)
Write a single raw byte value.- Parameters:
b- byte to be written- Returns:
- a int.
-
write
default int write(int b)
Write a single raw byte value.- Parameters:
b- integer value that will be cast to a byte and written- Returns:
- a int.
-
write
int write(byte[] data, int offset, int length)Write an array of byte values with given offset (starting position) and length in the provided data array.- Parameters:
data- data array of bytes to be writtenoffset- offset in data buffer to start atlength- number of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(byte[] data, int length)Write an array of byte values starting with the first byte in the array up to the provided length.- Parameters:
data- data array of bytes to be writtenlength- number of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(byte... data)
Write an array of byte values (all bytes in array).- Parameters:
data- data array of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(byte[]... data)
Write multiple byte arrays.- Parameters:
data- data array of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Collection<byte[]> data)
Write a collection of byte arrays.- Parameters:
data- collection of byte array of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(ByteBuffer buffer, int offset, int length)
Write a buffer of byte values with given offset (starting position) and length in the provided data buffer. NOTE: The buffer's internal position tracking is not used but rather only the explicit offset and length provided. If the requested length is greater than the buffers capacity (minus offset) then the specified length will be ignored and this function will only read the number of bytes up to the buffers' available space.- Parameters:
buffer- byte buffer of data to be writtenoffset- offset in data buffer to start atlength- number of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(ByteBuffer buffer, int length)
Write a buffer of byte values starting with the first byte in the array up to the provided length. NOTE: The contents from the byte buffer is read from the current position index up to the length requested or up to the buffer's remaining limit; whichever is is lower . If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- byte buffer of data to be writtenlength- number of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(ByteBuffer buffer)
Write a buffer of byte values (all bytes in buffer). NOTE: The contents from the byte buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- byte buffer of data to be written (from current position to limit)- Returns:
- The number of bytes written, possibly zero
-
write
default int write(ByteBuffer... buffer)
Write multiple byte buffers of data. NOTE: The contents from each byte buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- byte buffer of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(InputStream stream)
Write a stream of data (all bytes available in input stream).- Parameters:
stream- stream of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(InputStream stream, int length)
Write a stream of stream of data up to the length (number of bytes) specified.- Parameters:
stream- stream of data to be writtenlength- number of bytes to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(InputStream... stream)
Write multiple streams of data (all bytes available in each input stream).- Parameters:
stream- stream of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Charset charset, CharSequence data)
Writes a data string with specified character set (encoding).- Parameters:
data- string data (US_ASCII) to be writtencharset- character set to use for byte encoding- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Charset charset, CharSequence... data)
Writes a data string with specified character set (encoding).- Parameters:
data- string data (US_ASCII) to be writtencharset- character set to use for byte encoding- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Charset charset, Collection<CharSequence>... data)
Write a collection of ASCII character sequences with specified character set (encoding).- Parameters:
charset- character set to use for byte encodingdata- collection of character sequences of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(CharSequence data)
Writes an ASCII data string/character sequence.- Parameters:
data- string data (US_ASCII) to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(CharSequence... data)
Writes multiple ASCII data strings/character sequences.- Parameters:
data- string data (US_ASCII) to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Collection<CharSequence>... data)
Write a collection of ASCII character sequences.- Parameters:
data- collection of character sequences of data to be written- Returns:
- The number of bytes written, possibly zero
-
write
default int write(char[] data, int offset, int length)Writes an ASCII based character array (1 or more chars) with a given offset and length.- Parameters:
data- ASCII character array used for data writeoffset- offset in data character array to start atlength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(char[] data, int length)Writes an ASCII based character array (1 or more chars) with a given length starting from the 0 index position.- Parameters:
data- ASCII character array used for data writelength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(char... data)
Writes an ASCII based character array (1 or more chars).- Parameters:
data- ASCII character array used for data write- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, char[] data, int offset, int length)
Writes a character based array with a given offset and length. Specify the encoding to be used to encode the chars into bytes.- Parameters:
charset- character set to use for byte encodingdata- ASCII character array used for data writeoffset- offset in data character array to start atlength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, char[] data, int length)
Writes a character based array starting at the first index with a given length. Specify the encoding to be used to encode the chars into bytes.- Parameters:
charset- character set to use for byte encodingdata- ASCII character array used for data writelength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, char... data)
Writes a character array (1 or more chars).- Parameters:
data- character array (1 or more chars) to be writtencharset- character set to use for byte encoding- Returns:
- The number of bytes written, possibly zero
-
write
default int write(Charset charset, Collection<char[]> data)
Write a collection of character arrays. Specify the encoding to be used to encode the chars into bytes.- Parameters:
data- collection of character sequences of data to be writtencharset- aCharsetobject.- Returns:
- The number of bytes written, possibly zero
-
write
default int write(CharBuffer buffer, int offset, int length)
Writes an ASCII based character buffer with a given offset and length. NOTE: The buffer's internal position tracking is not used but rather only the explicit offset and length provided. If the requested length is greater than the buffers capacity (minus offset) then the specified length will be ignored and this function will only read the number of characters up to the buffers' available space.- Parameters:
buffer- ASCII character buffer used for data writeoffset- offset in data character array to start atlength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(CharBuffer buffer, int length) throws IOException
Writes an ASCII based character buffer starting at first index to a given length. NOTE: The contents from the character buffer is read from the current position index up to the length requested or up to the buffer's remaining limit; whichever is is lower . If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- ASCII character buffer used for data writelength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
- Throws:
IOException- thrown on write error
-
write
default int write(CharBuffer buffer)
Writes an ASCII based character buffer. NOTE: The contents from the character buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- ASCII character buffer used for data write- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(CharBuffer... buffer)
Writes multiple ASCII based character buffers. NOTE: The contents from each character buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
buffer- ASCII character buffer used for data write- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, CharBuffer buffer, int offset, int length)
Writes a character buffer with a given offset and length using a specified character set to encode the chars into bytes. NOTE: The buffer's internal position tracking is not used but rather only the explicit offset and length provided. If the requested length is greater than the buffers capacity (minus offset) then the specified length will be ignored and this function will only read the number of characters up to the buffers' available space.- Parameters:
charset- character set to use for byte encodingbuffer- character buffer used for data writeoffset- offset in data character array to start atlength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, CharBuffer buffer, int length)
Writes a character buffer starting at first index to a given length using a specified character set to encode the chars into bytes. NOTE: The contents from the character buffer is read from the current position index up to the length requested or up to the buffer's remaining limit; whichever is is lower . If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
charset- character set to use for byte encodingbuffer- character buffer used for data writelength- number of character in character array to be written- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, CharBuffer buffer)
Writes character buffer using a specified character set to encode the chars into bytes. NOTE: The contents from the character buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
charset- character set to use for byte encodingbuffer- character buffer used for data write- Returns:
- The number of bytes (not characters) written, possibly zero
-
write
default int write(Charset charset, CharBuffer... buffer)
Writes multiple character buffers using a specified character set to encode the chars into bytes. NOTE: The contents from each character buffer is read from the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically flip the buffer to begin reading data from the zero position up to the buffer's limit.- Parameters:
charset- character set to use for byte encodingbuffer- character buffer used for data write- Returns:
- The number of bytes (not characters) written, possibly zero
-
getOutputStream
default OutputStream getOutputStream()
Get an output stream to write data to- Returns:
- new output stream instance to write to
-
out
default OutputStream out()
Get an output stream to write data to- Returns:
- new output stream instance to write to
-
-