java.lang.Object
org.codelibs.jcifs.smb.impl.SmbRandomAccessFile
- All Implemented Interfaces:
DataInput,DataOutput,AutoCloseable,SmbRandomAccess
Random access file implementation for SMB resources.
Provides random read/write access to SMB files with support for seeking and positioning.
-
Constructor Summary
ConstructorsConstructorDescriptionSmbRandomAccessFile(String url, String mode, int sharing, CIFSContext tc) Instantiate a random access file from URLSmbRandomAccessFile(SmbFile file, String mode) Instantiate a random access file from aSmbFile -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the filelongCurrent position in filelonglength()Get the current file lengthvoidopen()Ensures that the file descriptor is openendintread()Read a single byte from the current positionintread(byte[] b) Read into buffer from current positionintread(byte[] b, int off, int len) Read into buffer from current positionfinal booleanfinal bytereadByte()final charreadChar()final doublefinal floatfinal voidreadFully(byte[] b) final voidreadFully(byte[] b, int off, int len) final intreadInt()final StringreadLine()final longreadLong()final shortfinal intfinal intfinal StringreadUTF()voidseek(long pos) Seek to new positionvoidsetLength(long newLength) Expand/truncate file lengthintskipBytes(int n) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) final voidwriteBoolean(boolean v) final voidwriteByte(int v) final voidwriteBytes(String s) final voidwriteChar(int v) final voidwriteChars(String s) final voidwriteDouble(double v) final voidwriteFloat(float v) final voidwriteInt(int v) final voidwriteLong(long v) final voidwriteShort(int v) final void
-
Constructor Details
-
SmbRandomAccessFile
public SmbRandomAccessFile(String url, String mode, int sharing, CIFSContext tc) throws SmbException, MalformedURLException Instantiate a random access file from URL- Parameters:
url- the SMB URL of the file to accessmode- the access mode ("r" for read-only, "rw" for read-write)sharing- the sharing flags for file accesstc- the CIFS context to use for the connection- Throws:
SmbException- if an SMB error occursMalformedURLException- if the URL is malformed
-
SmbRandomAccessFile
Instantiate a random access file from aSmbFile- Parameters:
file- the SmbFile to accessmode- the access mode ("r" for read-only, "rw" for read-write)- Throws:
SmbException- if an SMB error occurs
-
-
Method Details
-
open
Ensures that the file descriptor is openend- Throws:
CIFSException- if an error occurs opening the file
-
close
Description copied from interface:SmbRandomAccessClose the file- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSmbRandomAccess- Throws:
SmbException- if an I/O error occurs during close
-
read
Description copied from interface:SmbRandomAccessRead a single byte from the current position- Specified by:
readin interfaceSmbRandomAccess- Returns:
- read byte, -1 if EOF
- Throws:
SmbException- if an I/O error occurs during read
-
read
Description copied from interface:SmbRandomAccessRead into buffer from current position- Specified by:
readin interfaceSmbRandomAccess- Parameters:
b- buffer- Returns:
- number of bytes read
- Throws:
SmbException- if an I/O error occurs during read
-
read
Description copied from interface:SmbRandomAccessRead into buffer from current position- Specified by:
readin interfaceSmbRandomAccess- Parameters:
b- bufferoff- offset into bufferlen- read up tolenbytes- Returns:
- number of bytes read
- Throws:
SmbException- if an I/O error occurs during read
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
SmbException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
SmbException
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Throws:
SmbException
-
write
- Specified by:
writein interfaceDataOutput- Throws:
SmbException
-
write
- Specified by:
writein interfaceDataOutput- Throws:
SmbException
-
write
- Specified by:
writein interfaceDataOutput- Throws:
SmbException
-
getFilePointer
public long getFilePointer()Description copied from interface:SmbRandomAccessCurrent position in file- Specified by:
getFilePointerin interfaceSmbRandomAccess- Returns:
- current position
-
seek
public void seek(long pos) Description copied from interface:SmbRandomAccessSeek to new position- Specified by:
seekin interfaceSmbRandomAccess- Parameters:
pos- the new position to seek to
-
length
Description copied from interface:SmbRandomAccessGet the current file length- Specified by:
lengthin interfaceSmbRandomAccess- Returns:
- file length
- Throws:
SmbException- if an I/O error occurs
-
setLength
Description copied from interface:SmbRandomAccessExpand/truncate file length- Specified by:
setLengthin interfaceSmbRandomAccess- Parameters:
newLength- new file length- Throws:
SmbException- if an I/O error occurs
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
SmbException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
SmbException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
SmbException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
SmbException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
SmbException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
SmbException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
SmbException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
SmbException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
SmbException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
SmbException
-
readLine
- Specified by:
readLinein interfaceDataInput- Throws:
SmbException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
SmbException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
SmbException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Throws:
SmbException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Throws:
SmbException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Throws:
SmbException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Throws:
SmbException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Throws:
SmbException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
SmbException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
SmbException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Throws:
SmbException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Throws:
SmbException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
SmbException
-