Java バイトストリーム FileInputStream/FileOutputStream
FileInputStream
FileInputStream コンストラクタ
| コンストラクタ | 説明 |
|---|---|
| FileInputStream(String filePath) throws FileNotFoundException | filepath で指定したファイルに対する入力ストリームを生成する。 |
| FileInputStream(File fileObj) throws FileNotFoundException | fileObj で指定したファイルに対する入力ストリームを生成する。 |
| FileInputStream(FileDescriptor fdObj) throws SecurityException | fdObj によって既存の接続を表すファイルシステムの入力ストリームを生成する。 |
FileInputStream メソッド
| メソッド | 説明 |
|---|---|
| int available() throws IOException | 現在読み取れるバイト数を返す。 |
| int close() throws IOException | InputStream を閉じる。 |
| int read() throws IOException | InputStream から 1 バイトを読み取り、int 値として返す。 |
| int read(byte buf[]) throws IOException | InputStream から buf[] のサイズ分を読み取って buf に保存し、読み取ったバイト数を返す。 |
| int read(byte buf[], int offset, int numBytes) throws IOException | InputStream から numBytes 分を読み取り、buf[] の offset 位置から保存し、読み取ったバイト数を返す。 |
| int skip(long numBytes) throws IOException | numBytes で指定されたバイトをスキップし、スキップされたバイト数を返す。 |
| protected void finalize() | これ以上参照するものがない場合、close() メソッドを呼び出す。 |
| FileChannel getChannel() | FileInputStream の一意の FileChannel オブジェクトを返す。 |
| FileDescriptor getFD() | FileInputStream で実際のファイル接続に対する FileDescriptor オブジェクトを返す。 |
FileInputStream の例
準備中です。
FileOutputStream
FileOutputStream のコンストラクタ
| コンストラクタ | 説明 |
|---|---|
| FileOutputStream(String filepath) throws FileNotFoundException | filepath で指定したファイルに対する OutputStream を生成する。 |
| FileOutputStream(String filepath, boolean append) throws FileNotFoundException | 指定したファイルへの OutputStream を生成する。append 引数で出力時の append モードを設定する。 |
| FileOutputStream(File fileObj) throws FileNotFoundException | fileObj で指定されたファイルに対する OutputStream を生成する。 |
| FileOutputStream(File fileObj, boolean append) throws FileNotFoundException | fileObj で指定されたファイルに対する OutputStream を生成する。append 引数で出力時の append モードを設定する。 |
| FileOutputStream(FileDescriptor fdObj) throws NullPointerException | fdObj によって既存の接続を表すファイルシステムの OutputStream を生成する。 |
FileOutputStream メソッド
| メソッド | 説明 |
|---|---|
| void close() throws IOException | OutputStream を閉じる。 |
| void flush() throws IOException | バッファに残った OutputStream を出力する。 |
| void write(int i) throws IOException | 整数 i の下位 8 ビットを出力する。 |
| void write(byte buf[]) throws IOException | buf の内容を出力する。 |
| void write(byte buf[], int index, int size) throws IOException | buf の index 位置から size 分のバイトを出力する。 |
| FileChannel getChannel() | OutputStream と関連付けられた一意の FileChannel オブジェクトを返す。 |
| FileDescriptor getFD() | OutputStream と関連付けられた FileDescriptor オブジェクトを返す。 |
FileOutputStream の例
準備中です。