java.lang.Object
java.io.InputStream
org.codelibs.jcifs.smb.impl.SmbFileInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
SmbPipeInputStream
This InputStream can read bytes from a file on an SMB file server. Offsets are 64 bits.
-
Constructor Summary
ConstructorsConstructorDescriptionSmbFileInputStream(String url, CIFSContext tc) Creates an input stream for reading from the specified SMB URLSmbFileInputStream(SmbFile file) Creates anInputStreamfor reading bytes from a file on an SMB server represented by theSmbFileparameter. -
Method Summary
Modifier and TypeMethodDescriptionintThis stream class is unbuffered.voidclose()Closes this input stream and releases any system resources associated with the stream.voidopen()Ensures that the file descriptor is openendintread()Reads a byte of data from this input stream.intread(byte[] b) Reads up to b.length bytes of data from this input stream into an array of bytes.intread(byte[] b, int off, int len) Reads up to len bytes of data from this input stream into an array of bytes.intreadDirect(byte[] b, int off, int len) Reads up to len bytes of data from this input stream into an array of bytes.protected static IOExceptionseToIoe(SmbException se) Converts an SmbException to an IOExceptionlongskip(long n) Skip n bytes of data on this stream.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
SmbFileInputStream
Creates an input stream for reading from the specified SMB URL- Parameters:
url- the SMB URL to read fromtc- context to use- Throws:
SmbException- if an SMB error occursMalformedURLException- if the URL is malformed
-
SmbFileInputStream
Creates anInputStreamfor reading bytes from a file on an SMB server represented by theSmbFileparameter. SeeSmbFilefor a detailed description and examples of the smb URL syntax.- Parameters:
file- AnSmbFilespecifying the file to read from- Throws:
SmbException- if an SMB error occurs
-
-
Method Details
-
open
Ensures that the file descriptor is openend- Throws:
CIFSException- if an error occurs while opening the file
-
seToIoe
Converts an SmbException to an IOException- Parameters:
se- the SmbException to convert- Returns:
- an IOException wrapping the SmbException
-
close
Closes this input stream and releases any system resources associated with the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- if a network error occurs
-
read
Reads a byte of data from this input stream.- Specified by:
readin classInputStream- Throws:
IOException- if a network error occurs
-
read
Reads up to b.length bytes of data from this input stream into an array of bytes.- Overrides:
readin classInputStream- Throws:
IOException- if a network error occurs
-
read
Reads up to len bytes of data from this input stream into an array of bytes.- Overrides:
readin classInputStream- Throws:
IOException- if a network error occurs
-
readDirect
Reads up to len bytes of data from this input stream into an array of bytes.- Parameters:
b- the buffer to read intooff- the offset in the buffer to start writinglen- the maximum number of bytes to read- Returns:
- number of bytes read
- Throws:
IOException- if a network error occurs
-
available
This stream class is unbuffered. Therefore this method will always return 0 for streams connected to regular files. However, a stream created from a Named Pipe this method will query the server using a "peek named pipe" operation and return the number of available bytes on the server.- Overrides:
availablein classInputStream- Throws:
IOException
-
skip
Skip n bytes of data on this stream. This operation will not result in any IO with the server. UnlinkInputStreamvalue less than the one provided will not be returned if it exceeds the end of the file (if this is a problem let us know).- Overrides:
skipin classInputStream- Throws:
IOException
-