Secure store replacement for the java.io.RandomAccessFile class. More...
This class is a replacement for the java.io.RandomAccessFile class for accessing the BlackBerry Dynamics secure file system.
See the com.good.gd.file package documentation for an introduction to the secure file system.
This class supports both read and write operations, and maintains a file pointer for every open file. The file pointer can be repositioned forwards or backwards to any position in the file. This is different to the FileInputStream and FileOutputStream classes. The FileInputStream class supports only read operations. The FileOutputStream class supports only write operations and doesn't support repositioning of the file pointer.
This class has the same programming interface as the java.io.RandomAccessFile class, with the following exceptions.
"r", read-write "rw".
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
| RandomAccessFile (File file, String mode) throws FileNotFoundException | |
Constructor that opens a file in the secure store, from a File containing the path. More... | |
| RandomAccessFile (String file, String mode) throws FileNotFoundException | |
Constructor that opens a file in the secure store, from a String containing the path. More... | |
| int | read () throws IOException |
| Read one byte from a file in the secure store. More... | |
| int | read (byte[] b) throws IOException |
| Fill a byte buffer with data read from a file in the secure store. More... | |
| int | read (byte[] b, int off, int len) throws IOException |
| Read a specified amount of data from a file in the secure store into a byte buffer, at a specified offset. More... | |
| long | getFilePointer () throws IOException |
| Returns the current position of the file pointer in an open file in the secure store. More... | |
| void | seek (long pos) throws IOException |
| Reposition the file pointer of an open file in the secure store. More... | |
| long | length () throws IOException |
| Get the length of a file in the secure store. More... | |
| void | setLength (long newLength) throws IOException |
| Set the length of a file in the secure store. More... | |
| void | close () |
| Close a file in the secure store. More... | |
| void | write (int b) throws IOException |
| Write one byte to a file in the secure store. More... | |
| void | write (byte[] b) throws IOException |
| Write a byte buffer to a file in the secure store. More... | |
| void | write (byte[] b, int off, int len) throws IOException |
| Write a specified amount of data, from a specified offset into a byte buffer, into a file in the secure store. More... | |
| void | writeBoolean (boolean val) throws IOException |
Write a boolean value to a file in the secure store, as a single byte. More... | |
| void | writeByte (int val) throws IOException |
| Write one byte to a file in the secure store. More... | |
| void | writeBytes (String str) throws IOException |
Write bytes from a String to a file in the secure store. More... | |
| void | writeChar (int val) throws IOException |
| Write a two-byte character to a file in the secure store. More... | |
| void | writeChars (String str) throws IOException |
Write two-byte characters from a String to a file in the secure store. More... | |
| void | writeDouble (double val) throws IOException |
Write a double value to a file in the secure store. More... | |
| void | writeFloat (float val) throws IOException |
Write a float value to a file in the secure store. More... | |
| void | writeInt (int val) throws IOException |
Write an int value to a file in the secure store. More... | |
| void | writeLong (long val) throws IOException |
Write a long value to a file in the secure store. More... | |
| void | writeShort (int val) throws IOException |
Write a short value to a file in the secure store. More... | |
| void | writeUTF (String str) throws IOException |
Write a UTF-8 representation of a String to a file in the secure store. More... | |
| boolean | readBoolean () throws IOException |
Read a boolean from a file in the secure store. More... | |
| byte | readByte () throws IOException |
| Read a byte from a file in the secure store. More... | |
| char | readChar () throws IOException |
| Read a two-byte character from a file in the secure store. More... | |
| double | readDouble () throws IOException |
Read a double from a file in the secure store. More... | |
| float | readFloat () throws IOException |
Read a float from a file in the secure store. More... | |
| final void | readFully (byte[] b) throws IOException |
| Fill a byte buffer with data read from a file in the secure store. More... | |
| final void | readFully (byte[] b, int off, int len) throws IOException |
| Read a specified amount of data from a file in the secure store into a byte buffer, at a specified offset. More... | |
| int | readInt () throws IOException |
Read an int from a file in the secure store. More... | |
| String | readLine () throws IOException |
| Read a line of text from a file in the secure store. More... | |
| long | readLong () throws IOException |
Read a long from a file in the secure store. More... | |
| short | readShort () throws IOException |
Read a short from a file in the secure store. More... | |
| String | readUTF () throws IOException |
Read a UTF-8 String from a file in the secure store. More... | |
| int | readUnsignedByte () throws IOException |
| Read an unsigned byte from a file in the secure file system. More... | |
| int | readUnsignedShort () throws IOException |
Read an unsigned short from a file in the secure file system. More... | |
| int | skipBytes (int n) throws IOException |
| Skip a number of bytes in an open file in the secure system. More... | |
| RandomAccessFile | ( | File | file, |
| String | mode | ||
| ) | throws FileNotFoundException |
Call this constructor to open a file in the secure store, in the specified mode. The specified mode can be read-only or read-write.
| file | File containing the path of the file to open, in the secure file system. |
| mode | String specifying the mode: "r" for read-only, "rw" for read-write. |
| FileNotFoundException | |
| com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
| RandomAccessFile | ( | String | file, |
| String | mode | ||
| ) | throws FileNotFoundException |
Call this constructor to open a file in the secure store, in the specified mode. The specified mode can be read-only or read-write.
| file | String containing the path of the file to open, in the secure file system. |
| mode | String specifying the mode: "r" for read-only, "rw" for read-write. |
| FileNotFoundException | |
| com.good.gd.error.GDNotAuthorizedError | if BlackBerry Dynamics authorization processing has not yet completed. |
| int read | ( | ) | throws IOException |
Call this method to read one byte from an open file in the secure store. Reading this data advances the file pointer by one byte.
int representation of the next byte of data, or -1 if the end of the file has been reached.| IOException |
| int read | ( | byte[] | b | ) | throws IOException |
Call this method to read data from a file in the secure store into a byte buffer. Reading data advances the file pointer by the number of bytes read. No more data will be read than can be stored in the buffer.
| b | byte array into which data will be read. |
int representation of the number of bytes actually read, or -1 if the end of the file has been reached.| IOException |
| int read | ( | byte[] | b, |
| int | off, | ||
| int | len | ||
| ) | throws IOException |
Call this method to read data from a file in the secure store into a byte buffer. The data that is read will be written into the buffer starting at a specified offset. Reading data advances the file pointer by the number of bytes read. No more data will be read than a specified maximum.
| b | byte array for the buffer into which data will be written. |
| off | int offset into the buffer, at which writing is to begin. |
| len | int maximum number of bytes to read. |
int representation of the number of bytes actually read, or -1 if the end of the file has been reached.| IOException |
| long getFilePointer | ( | ) | throws IOException |
Call this method to get the current position of the file pointer in an open file in the secure store. The position is returned as a number of bytes offset from the start of the file.
long representation of the current position of the file pointer.| IOException |
| void seek | ( | long | pos | ) | throws IOException |
Call this method to set the position of the file pointer in an open file in the secure store. The required position is specified as a number of bytes offset from the start of the file.
| pos | long representation of the required position of the file pointer. |
| IOException |
| long length | ( | ) | throws IOException |
long representation of the length of the file in bytes.| IOException |
| void setLength | ( | long | newLength | ) | throws IOException |
Call this method to set the length of an open file in the secure store. The required length is specified as a number of bytes.
If the specified length is greater than the current file length, then the file will be padded out to the specified length. If the length is less than the current file length, then the file will be truncated.
| newLength | long representation of the required length of the file. |
| IOException |
| void close | ( | ) |
Call this method to close an open file in the secure store. Any resources associated with the open file's stream will be released. Data that is pending write will be committed to the secure store.
Calling this method is the only way to confirm finalisation of writing data to the secure file system.
| void write | ( | int | b | ) | throws IOException |
Call this method to write one byte of data to a file in the secure store. Writing this data advances the file pointer by one byte.
| b | int representation of the byte to write. |
| IOException |
| void write | ( | byte[] | b | ) | throws IOException |
Call this method to write bytes from an array into a file in the secure store. The file pointer will advance by the number of bytes written.
| b | byte array from which to write. |
| IOException |
| void write | ( | byte[] | b, |
| int | off, | ||
| int | len | ||
| ) | throws IOException |
Call this method to write a specified amount of data from a byte buffer into a file in the secure store. The data will be read from the buffer, starting at a specified offset. The file pointer will advance by the number of bytes written.
| b | byte array for the buffer from which data will be read. |
| off | int offset into the buffer, from which reading is to begin. |
| len | int maximum number of bytes to write. |
| IOException |
| void writeBoolean | ( | boolean | val | ) | throws IOException |
Call this method to write a boolean value to a file in the secure store. The value is written as a single byte, so the file pointer advances by one byte when this data is written.
| val | boolean value to write. |
| IOException |
| void writeByte | ( | int | val | ) | throws IOException |
Call this method to write one byte of data to a file in the secure store. Writing this data advances the file pointer by one byte.
| val | int representation of the byte to write. |
| IOException |
| void writeBytes | ( | String | str | ) | throws IOException |
Call this method to write bytes from a String into a file in the secure store. One byte will be written for each character in the string, with the high eight bits of each character being discarded. The file pointer will advance by the number of bytes written.
| str | String from which to write bytes. |
| IOException |
| void writeChar | ( | int | val | ) | throws IOException |
Call this method to write a two-byte character to a file in the secure store. The high byte will be written first. The file pointer will advance by two bytes.
| val | int representation of the character to write. |
| IOException |
| void writeChars | ( | String | str | ) | throws IOException |
Call this method to write two-byte characters from a String into a file in the secure store. Each character is written as if the writeChar method had been called. The file pointer will advance by the number of bytes written.
| str | String to write. |
| IOException |
| void writeDouble | ( | double | val | ) | throws IOException |
Call this method to write a double value to a file in the secure store. The doubleToLongBits method in the Double class is used to generate a byte representation of the value. The file pointer will advance by the number of bytes written.
| val | double to write. |
| IOException |
java.lang.Double class reference on the android.com developer website. | void writeFloat | ( | float | val | ) | throws IOException |
Call this method to write a float value to a file in the secure store. The floatToIntBits method in the Float class is used to generate a byte representation of the value. The file pointer will advance by the number of bytes written.
| val | float to write. |
| IOException |
java.lang.Float class reference on the android.com developer website. | void writeInt | ( | int | val | ) | throws IOException |
Call this method to write an int value to a file in the secure store. The bytes are written in order from most significant to least significant. The file pointer will advance by the number of bytes written.
| val | int to write. |
| IOException |
| void writeLong | ( | long | val | ) | throws IOException |
Call this method to write a long value to a file in the secure store. The bytes are written in order from most significant to least significant. The file pointer will advance by the number of bytes written.
| val | long to write. |
| IOException |
| void writeShort | ( | int | val | ) | throws IOException |
Call this method to write a short value to a file in the secure store. The bytes are written in order from most significant to least significant. The file pointer will advance by the number of bytes written.
| val | short to write. |
| IOException |
| void writeUTF | ( | String | str | ) | throws IOException |
Call this method to write the characters from a String into a file in the secure store. The UTF-8 representations of the string will be written, which will include an explicit length. The file pointer will advance by the number of bytes written.
| str | String to write. |
| IOException |
| boolean readBoolean | ( | ) | throws IOException |
Call this method to read a boolean value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeBoolean method. The file pointer will advance by one byte.
boolean representation of the byte at the file pointer.| IOException |
| byte readByte | ( | ) | throws IOException |
Call this method to read a byte from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeByte method. The file pointer will advance by one byte.
int representation of the byte at the file pointer.| IOException |
| char readChar | ( | ) | throws IOException |
Call this method to read a two-byte character from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeChar method. The file pointer will advance by two bytes.
char representation of the data at the file pointer.| IOException |
| double readDouble | ( | ) | throws IOException |
Call this method to read a double value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeDouble method. The longBitsToDouble method in the Double class is used to generate a value from the data in the file. The file pointer will advance by the number of bytes read.
double representation of the data at the file pointer.| IOException |
java.lang.Double class reference on the android.com developer website. | float readFloat | ( | ) | throws IOException |
Call this method to read a float value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeFloat method. The intBitsToFloat method in the Double class is used to generate a value from the data in the file. The file pointer will advance by the number of bytes read.
float representation of the data at the file pointer.| IOException |
java.lang.Float class reference on the android.com developer website. | final void readFully | ( | byte[] | b | ) | throws IOException |
Call this method to read data from a file in the secure store into a byte buffer. Enough data to fill the buffer will be read from the file, if possible. If there isn't enough data remaining in the file, an exception will be thrown. The file pointer will advance by the number of bytes read.
| b | byte array for the buffer into which data will be read from the file pointer. |
| IOException |
| final void readFully | ( | byte[] | b, |
| int | off, | ||
| int | len | ||
| ) | throws IOException |
Call this method to read data from a file in the secure store into a byte buffer. The data that is read will be written into the buffer starting at a specified offset. A specified number of bytes will be read from the file, if possible. If there isn't enough data remaining in the file, an exception will be thrown. The file pointer will advance by the number of bytes read.
| b | byte array for the buffer into which data will be written. |
| off | int offset into the buffer, at which writing is to begin. |
| len | int maximum number of bytes to read. |
| IOException |
| int readInt | ( | ) | throws IOException |
Call this method to read an int value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeInt method. The file pointer will advance by the number of bytes read.
int representation of the data at the file pointer.| IOException |
| String readLine | ( | ) | throws IOException |
Call this method to read a line of text from a file in the secure store. The file pointer will advance past the line termination sequence, if there is one, or to the end of the file otherwise.
String representation of the line read from the file pointer. The line termination sequence, if any, is discarded.| IOException |
| long readLong | ( | ) | throws IOException |
Call this method to read an long value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeLong method. The file pointer will advance by the number of bytes read.
long representation of the data at the file pointer.| IOException |
| short readShort | ( | ) | throws IOException |
Call this method to read a short value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeShort method. The file pointer will advance by the number of bytes read.
short representation of the data at the file pointer.| IOException |
| String readUTF | ( | ) | throws IOException |
Call this method to read a UTF-8 String value from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeUTF method. The file pointer will advance by the number of bytes read.
String representation of the data at the file pointer.| IOException |
| int readUnsignedByte | ( | ) | throws IOException |
Call this method to read an unsigned byte from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeByte method when passed an unsigned value. The file pointer will advance by one byte.
int representation of the byte at the file pointer.| IOException |
| int readUnsignedShort | ( | ) | throws IOException |
Call this method to read an unsigned short from a file in the secure store. Representation of the data in the file is assumed to be the same as that used by the writeShort method when passed an unsigned value. The file pointer will advance by the number of bytes read.
int representation of the unsigned short at the file pointer.| IOException |
| int skipBytes | ( | int | n | ) | throws IOException |
Call this method to advance the file pointer of an open file in the secure store without reading or writing data.
Advancing the specified number of bytes specified might be impossible, for example if there are fewer bytes remaining after the file pointer. In that case, the file pointer will advance to the end of the file.
| n | int specifying the number of bytes to advance. |
int representation of the number of bytes actually advanced.| IOException |