• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
FileOutputStream Class Reference

Extension of java.io.OutputStream for writing data to the secure file system. More...

Inheritance diagram for FileOutputStream:
OutputStream

Description

This class is a subclass of java.io.OutputStream for writing data to the BlackBerry Dynamics secure file system.

See the com.good.gd.file package documentation for an introduction to the secure file system.

This class has the same programming interface as the java.io.FileOutputStream class, which inherits from java.io.OutputStream, with the following exceptions.

  • FileChannel isn't supported. There is no getChannel method.
  • FileDescriptor isn't supported. There is no getFD method. There is no constructor to create a stream from a descriptor.
  • Flushing separately to closing isn't supported. Calling the flush method has no effect.

See also
The java.io.FileOutputStream and java.io.OutputStream class references on the android.com developer website for details of all methods.

Notice

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

 FileOutputStream (File file) throws FileNotFoundException
 Constructor that opens a file for writing, from a File containing the path in the secure store. More...
 
 FileOutputStream (File file, boolean append) throws FileNotFoundException
 Constructor that opens a file for writing in overwrite or append mode, from a File containing the path in the secure store. More...
 
 FileOutputStream (String path) throws FileNotFoundException
 Constructor that opens a file for writing, from a String containing the path in the secure store. More...
 
 FileOutputStream (String path, boolean append) throws FileNotFoundException
 Constructor that opens a file for writing in overwrite or append mode, from a String containing the path in the secure store. More...
 
void write (int b) throws IOException
 Write one byte to an open file in the secure store. More...
 
void write (byte[] b) throws IOException
 Write a byte buffer to an open 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 an open file in the secure store. More...
 
void flush () throws IOException
 Flush an open file in the secure store. More...
 
void close () throws IOException
 Close a file in the secure store. More...
 

Constructor & Destructor Documentation

◆ FileOutputStream() [1/4]

FileOutputStream ( File  file) throws FileNotFoundException

Call this constructor to open a file in the secure store, for writing. If there is already a file at the specified path, the file is truncated.

Parameters
fileFile containing the path of the file to open, in the secure file system.
Exceptions
FileNotFoundException
com.good.gd.error.GDNotAuthorizedErrorif BlackBerry Dynamics authorization processing has not yet completed.

◆ FileOutputStream() [2/4]

FileOutputStream ( File  file,
boolean  append 
) throws FileNotFoundException

Call this constructor to open a file in the secure store, for writing. If a file already exists at the specified path, the file can either be appended to, or overwritten.

Parameters
fileFile containing the path of the file to open, in the secure file system.
appendboolean Selects the action to take if a file already exists at the path: true to append to the file, or false to overwrite.
Exceptions
FileNotFoundException
com.good.gd.error.GDNotAuthorizedErrorif BlackBerry Dynamics authorization processing has not yet completed.

◆ FileOutputStream() [3/4]

FileOutputStream ( String  path) throws FileNotFoundException

Call this constructor to open a file in the secure store, for writing. If there is already a file at the specified path, the file is truncated.

Parameters
pathString containing the path of the file to open, in the secure file system.
Exceptions
FileNotFoundException
com.good.gd.error.GDNotAuthorizedErrorif BlackBerry Dynamics authorization processing has not yet completed.

◆ FileOutputStream() [4/4]

FileOutputStream ( String  path,
boolean  append 
) throws FileNotFoundException

Call this constructor to open a file in the secure store, for writing. If a file already exists at the specified path, the file can either be appended to, or overwritten.

Parameters
pathString containing the path of the file to open, in the secure file system.
appendboolean Selects the action to take if a file already exists at the path: true to append to the file, or false to overwrite.
Exceptions
FileNotFoundException
com.good.gd.error.GDNotAuthorizedErrorif BlackBerry Dynamics authorization processing has not yet completed.

Member Function Documentation

◆ write() [1/3]

void write ( int  b) throws IOException
Parameters
bint representation of the byte to write to the open file, in the secure store.
Exceptions
IOException

◆ write() [2/3]

void write ( byte[]  b) throws IOException
Parameters
bbyte array to write to the open file, in the secure store.
Exceptions
IOException

◆ write() [3/3]

void write ( byte[]  b,
int  off,
int  len 
) throws IOException

Call this method to write 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.

Parameters
bbyte array for the buffer from which data will be read.
offint offset into the buffer, from which reading is to begin.
lenint maximum number of bytes to write.
Exceptions
IOException

◆ flush()

void flush ( ) throws IOException

The secure file system doesn't support separate flushing and closing of files. Calling this method has no effect.

◆ close()

void close ( ) throws IOException

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.