dw.io
Class RandomAccessFileReader
Object
dw.io.RandomAccessFileReader
Instances of this class support reading from a random access file. A random access file behaves like a large array of bytes stored in the file system. There is a kind of cursor, or index into the implied array, called the file pointer. Read operations read bytes starting at the file pointer and advance the file pointer past the bytes read. The file pointer can be read by the getPosition method and set by the setPosition method.
Constants
MAX_READ_BYTES  :  Number = 10240L
The maximum number of bytes that a single call to readBytes(Number) can return == 10KB
Properties
position  :  Number
The current offset in this file.
Constructor Summary
RandomAccessFileReader(file : File)
Construct a reader for random read access to the provided file.
Method Summary
close() : void
Closes this random access file reader and releases any system resources associated with the stream.
getPosition() : Number
Returns the current offset in this file.
length() : Number
Returns the length of this file.
readByte() : Number
Reads a signed eight-bit value from the file starting from the current file pointer.
readBytes(numBytes : Number) : Bytes
Reads up to n bytes from the file starting at the current file pointer.
setPosition(position : Number) : void
Sets the file-pointer offset, measured from the beginning of this file, at which the next read occurs.
Salesforce Commerce Cloud Courses
Salesforce B2C Commerce Developer - Certification Tests
Why risk failing the SFCC exam? Get 180 real questions, killer content, and everything you need to crush the Salesforce B2C Commerce Developer certification.

Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβ€”passing the certification exam isn't easy. That's where we come in.
Salesforce Javascript Developer I - Certification Tests
Not just another prep courseβ€”this is your shortcut to passing. Master JavaScript for Salesforce and go from 'hoping to pass' to knowing you will. Ready to start?

This isn't just another prep courseβ€”it's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
Salesforce B2C Commerce Architect - Certification Tests
Think the Developer exam was hard? Welcome to the next level.

The Salesforce B2C Commerce Architect certification is a whole different gameβ€”complex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
Constructor Detail
RandomAccessFileReader
public RandomAccessFileReader(file : File)
Construct a reader for random read access to the provided file.

To release system resources, close the reader by calling close().

Parameters:
file - The file to be read. Must not be null.
Throws:
IOException - If the given file object does not denote an existing regular file

Method Detail
close
close() : void
Closes this random access file reader and releases any system resources associated with the stream.
Throws:
IOException - if an I/O error occurs.

getPosition
getPosition() : Number
Returns the current offset in this file.
Returns:
the offset from the beginning of the file, in bytes, at which the next read occurs.
Throws:
IOException - if an I/O error occurs.

length
length() : Number
Returns the length of this file.
Returns:
the length of this file, measured in bytes.
Throws:
IOException - if an I/O error occurs.

readByte
readByte() : Number
Reads a signed eight-bit value from the file starting from the current file pointer. Since the byte is interpreted as signed, the value returned will always be between -128 and +127.
Returns:
the next byte of this file as a signed eight-bit byte.
Throws:
IOException - if an I/O error occurs or if this file has reached the end.

readBytes
readBytes(numBytes : Number) : Bytes
Reads up to n bytes from the file starting at the current file pointer. If there are fewer than n bytes remaining in the file, then as many bytes as possible are read. If no bytes remain in the file, then null is returned.
Parameters:
numBytes - The number of bytes to read. Must be non-negative and smaller than MAX_READ_BYTES or an exception will be thrown.
Returns:
A Bytes object representing the read bytes or null if no bytes were read.
Throws:
IOException - if an I/O error occurs.
IllegalArgumentException - if numBytes< 0 or numBytes > MAX_READ_BYTES.

setPosition
setPosition(position : Number) : void
Sets the file-pointer offset, measured from the beginning of this file, at which the next read occurs. The offset may be set beyond the end of the file.
Parameters:
position - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer
Throws:
IOException - if position is less than 0 or if an I/O error occurs.

β™₯
Notifications pending to read