Package jcifs.smb
Class SmbRandomAccessFile
- java.lang.Object
-
- jcifs.smb.SmbRandomAccessFile
-
- All Implemented Interfaces:
DataInput,DataOutput,AutoCloseable,SmbRandomAccess
public class SmbRandomAccessFile extends Object implements SmbRandomAccess
-
-
Constructor Summary
Constructors Constructor Description SmbRandomAccessFile(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the filelonggetFilePointer()Current 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 positionbooleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()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)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)voidwriteChar(int v)voidwriteChars(String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteShort(int v)voidwriteUTF(String str)
-
-
-
Constructor Detail
-
SmbRandomAccessFile
public SmbRandomAccessFile(String url, String mode, int sharing, CIFSContext tc) throws SmbException, MalformedURLException
Instantiate a random access file from URL- Parameters:
url-mode-sharing-tc-- Throws:
SmbExceptionMalformedURLException
-
SmbRandomAccessFile
public SmbRandomAccessFile(SmbFile file, String mode) throws SmbException
Instantiate a random access file from aSmbFile- Parameters:
file-mode-- Throws:
SmbException
-
-
Method Detail
-
open
public void open() throws CIFSExceptionEnsures that the file descriptor is openend- Throws:
CIFSException
-
close
public void close() throws SmbExceptionDescription copied from interface:SmbRandomAccessClose the file- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSmbRandomAccess- Throws:
SmbException
-
read
public int read() throws SmbExceptionDescription copied from interface:SmbRandomAccessRead a single byte from the current position- Specified by:
readin interfaceSmbRandomAccess- Returns:
- read byte, -1 if EOF
- Throws:
SmbException
-
read
public int read(byte[] b) throws SmbExceptionDescription copied from interface:SmbRandomAccessRead into buffer from current position- Specified by:
readin interfaceSmbRandomAccess- Parameters:
b- buffer- Returns:
- number of bytes read
- Throws:
SmbException
-
read
public int read(byte[] b, int off, int len) throws SmbExceptionDescription copied from interface:SmbRandomAccessRead into buffer from current position- Specified by:
readin interfaceSmbRandomAccess- Parameters:
b- bufferoff- offset into bufferlen- read up to len bytes- Returns:
- number of bytes read
- Throws:
SmbException
-
readFully
public final void readFully(byte[] b) throws SmbException- Specified by:
readFullyin interfaceDataInput- Throws:
SmbException
-
readFully
public final void readFully(byte[] b, int off, int len) throws SmbException- Specified by:
readFullyin interfaceDataInput- Throws:
SmbException
-
skipBytes
public int skipBytes(int n) throws SmbException- Specified by:
skipBytesin interfaceDataInput- Throws:
SmbException
-
write
public void write(int b) throws SmbException- Specified by:
writein interfaceDataOutput- Throws:
SmbException
-
write
public void write(byte[] b) throws SmbException- Specified by:
writein interfaceDataOutput- Throws:
SmbException
-
write
public void write(byte[] b, int off, int len) throws SmbException- 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
-
length
public long length() throws SmbExceptionDescription copied from interface:SmbRandomAccessGet the current file length- Specified by:
lengthin interfaceSmbRandomAccess- Returns:
- file length
- Throws:
SmbException
-
setLength
public void setLength(long newLength) throws SmbExceptionDescription copied from interface:SmbRandomAccessExpand/truncate file length- Specified by:
setLengthin interfaceSmbRandomAccess- Parameters:
newLength- new file length- Throws:
SmbException
-
readBoolean
public final boolean readBoolean() throws SmbException- Specified by:
readBooleanin interfaceDataInput- Throws:
SmbException
-
readByte
public final byte readByte() throws SmbException- Specified by:
readBytein interfaceDataInput- Throws:
SmbException
-
readUnsignedByte
public final int readUnsignedByte() throws SmbException- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
SmbException
-
readShort
public final short readShort() throws SmbException- Specified by:
readShortin interfaceDataInput- Throws:
SmbException
-
readUnsignedShort
public final int readUnsignedShort() throws SmbException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
SmbException
-
readChar
public final char readChar() throws SmbException- Specified by:
readCharin interfaceDataInput- Throws:
SmbException
-
readInt
public final int readInt() throws SmbException- Specified by:
readIntin interfaceDataInput- Throws:
SmbException
-
readLong
public final long readLong() throws SmbException- Specified by:
readLongin interfaceDataInput- Throws:
SmbException
-
readFloat
public final float readFloat() throws SmbException- Specified by:
readFloatin interfaceDataInput- Throws:
SmbException
-
readDouble
public final double readDouble() throws SmbException- Specified by:
readDoublein interfaceDataInput- Throws:
SmbException
-
readLine
public final String readLine() throws SmbException
- Specified by:
readLinein interfaceDataInput- Throws:
SmbException
-
readUTF
public final String readUTF() throws SmbException
- Specified by:
readUTFin interfaceDataInput- Throws:
SmbException
-
writeBoolean
public final void writeBoolean(boolean v) throws SmbException- Specified by:
writeBooleanin interfaceDataOutput- Throws:
SmbException
-
writeByte
public final void writeByte(int v) throws SmbException- Specified by:
writeBytein interfaceDataOutput- Throws:
SmbException
-
writeShort
public final void writeShort(int v) throws SmbException- Specified by:
writeShortin interfaceDataOutput- Throws:
SmbException
-
writeChar
public final void writeChar(int v) throws SmbException- Specified by:
writeCharin interfaceDataOutput- Throws:
SmbException
-
writeInt
public final void writeInt(int v) throws SmbException- Specified by:
writeIntin interfaceDataOutput- Throws:
SmbException
-
writeLong
public final void writeLong(long v) throws SmbException- Specified by:
writeLongin interfaceDataOutput- Throws:
SmbException
-
writeFloat
public final void writeFloat(float v) throws SmbException- Specified by:
writeFloatin interfaceDataOutput- Throws:
SmbException
-
writeDouble
public final void writeDouble(double v) throws SmbException- Specified by:
writeDoublein interfaceDataOutput- Throws:
SmbException
-
writeBytes
public final void writeBytes(String s) throws SmbException
- Specified by:
writeBytesin interfaceDataOutput- Throws:
SmbException
-
writeChars
public final void writeChars(String s) throws SmbException
- Specified by:
writeCharsin interfaceDataOutput- Throws:
SmbException
-
writeUTF
public final void writeUTF(String str) throws SmbException
- Specified by:
writeUTFin interfaceDataOutput- Throws:
SmbException
-
-