Package com.zerotier.sockets
Class ZeroTierInputStream
java.lang.Object
java.io.InputStream
com.zerotier.sockets.ZeroTierInputStream
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ZeroTierInputStream
extends java.io.InputStream
Extends InputStream using ZeroTier as a transport
-
Field Summary
Fields Modifier and Type Field Description int
zfd
File descriptor used by lower native layer -
Constructor Summary
Constructors Constructor Description ZeroTierInputStream()
-
Method Summary
Modifier and Type Method Description void
close()
Close the ZeroTierInputStreamint
read()
Read a single byte from the streamint
read(byte[] destBuffer)
Read from stream into bufferint
read(byte[] destBuffer, int offset, int numBytes)
Read from stream into buffer at offsetbyte[]
readAllBytes()
Read all available data from streamint
readNBytes(byte[] destBuffer, int offset, int numBytes)
Read a given number of bytes from the stream into a bufferlong
skip(long numBytes)
Skip a certain number of byteslong
transferTo(java.io.OutputStream destStream)
Transfer bytes from this stream to anotherMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readNBytes, reset, skipNBytes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
zfd
public int zfdFile descriptor used by lower native layer
-
-
Constructor Details
-
ZeroTierInputStream
public ZeroTierInputStream()
-
-
Method Details
-
close
public void close() throws java.io.IOExceptionClose the ZeroTierInputStream- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
- when an I/O error occurs
-
transferTo
public long transferTo(java.io.OutputStream destStream) throws java.io.IOExceptionTransfer bytes from this stream to another- Overrides:
transferTo
in classjava.io.InputStream
- Parameters:
destStream
- Unused- Returns:
- Number of bytes transferred
- Throws:
java.io.IOException
- when an I/O error occurs
-
read
public int read() throws java.io.IOExceptionRead a single byte from the stream- Specified by:
read
in classjava.io.InputStream
- Returns:
- Single byte read
- Throws:
java.io.IOException
- when an I/O error occurs
-
read
public int read(byte[] destBuffer) throws java.io.IOExceptionRead from stream into buffer- Overrides:
read
in classjava.io.InputStream
- Parameters:
destBuffer
- Destination buffer- Returns:
- Number of bytes read
- Throws:
java.io.IOException
- when an I/O error occurs
-
read
public int read(byte[] destBuffer, int offset, int numBytes) throws java.io.IOExceptionRead from stream into buffer at offset- Overrides:
read
in classjava.io.InputStream
- Parameters:
destBuffer
- Destination bufferoffset
- Where in the destination buffer bytes should be writtennumBytes
- Number of bytes to read- Returns:
- Number of bytes read.
- Throws:
java.io.IOException
- when an I/O error occurs
-
readAllBytes
public byte[] readAllBytes() throws java.io.IOExceptionRead all available data from stream- Overrides:
readAllBytes
in classjava.io.InputStream
- Returns:
- Array of bytes
- Throws:
java.io.IOException
- when an I/O error occurs
-
readNBytes
public int readNBytes(byte[] destBuffer, int offset, int numBytes) throws java.io.IOExceptionRead a given number of bytes from the stream into a buffer- Overrides:
readNBytes
in classjava.io.InputStream
- Parameters:
destBuffer
- Destination bufferoffset
- Where in the destination buffer bytes should be writtennumBytes
- Number of bytes to read- Returns:
- Nothing.
- Throws:
java.io.IOException
- when an I/O error occurs
-
skip
public long skip(long numBytes) throws java.io.IOExceptionSkip a certain number of bytes- Overrides:
skip
in classjava.io.InputStream
- Parameters:
numBytes
- Unused- Returns:
- Nothing.
- Throws:
java.io.IOException
- when an I/O error occurs
-