net.i2p.util

## Class SecureFileOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FileOutputStream
    - - net.i2p.util.SecureFileOutputStream

- All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

      public class SecureFileOutputStream
      extends FileOutputStream

  Same as FileOutputStream but sets the file mode so it can only be read and written by the owner only (i.e. 600 on linux)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SecureFileOutputStream(File file)` Sets output file to mode 600
    `SecureFileOutputStream(File file, boolean append)` Sets output file to mode 600 only if append = false (otherwise it is presumed to be 600 already)
    `SecureFileOutputStream(String file)` Sets output file to mode 600
    `SecureFileOutputStream(String file, boolean append)` Sets output file to mode 600 whether append = true or false

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) static boolean` | `canSetPerms()`
    `static void` | `setPerms(File f)` Tries to set the permissions to 600, ignores errors

    - ### Methods inherited from class java.io.FileOutputStream

      `close, finalize, getChannel, getFD, write, write, write`

    - ### Methods inherited from class java.io.OutputStream

      `flush`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SecureFileOutputStream

          public SecureFileOutputStream(File file)
                                 throws FileNotFoundException

      Sets output file to mode 600
      Throws:
        `FileNotFoundException`

    - #### SecureFileOutputStream

          public SecureFileOutputStream(File file,
                                        boolean append)
                                 throws FileNotFoundException

      Sets output file to mode 600 only if append = false (otherwise it is presumed to be 600 already)
      Throws:
        `FileNotFoundException`

    - #### SecureFileOutputStream

          public SecureFileOutputStream(String file)
                                 throws FileNotFoundException

      Sets output file to mode 600
      Throws:
        `FileNotFoundException`

    - #### SecureFileOutputStream

          public SecureFileOutputStream(String file,
                                        boolean append)
                                 throws FileNotFoundException

      Sets output file to mode 600 whether append = true or false
      Throws:
        `FileNotFoundException`

  - ### Method Detail

    - #### canSetPerms

          static boolean canSetPerms()

    - #### setPerms

          public static void setPerms(File f)

      Tries to set the permissions to 600, ignores errors