A specialized OutputStream that writes to a file in the file system. All write requests made by calling methods in this class are directly forwarded to the equivalent function of the underlying operating system. Since this may induce some performance penalty, in particular if many small writ
| 33 | * @see FileInputStream |
| 34 | */ |
| 35 | public class FileOutputStream extends OutputStream implements Closeable { |
| 36 | |
| 37 | /** |
| 38 | * The FileDescriptor representing this FileOutputStream. |
| 39 | */ |
| 40 | FileDescriptor fd; |
| 41 | |
| 42 | // The unique file channel associated with this FileInputStream (lazily |
| 43 | // initialized). |
| 44 | // private FileChannel channel; |
| 45 | |
| 46 | private IFileSystem fileSystem = Platform.getFileSystem(); |
| 47 | |
| 48 | /** |
| 49 | * Constructs a new FileOutputStream on the File {@code file}. If the file |
| 50 | * exists, it is overwritten. |
| 51 | * |
| 52 | * @param file |
| 53 | * the file to which this stream writes. |
| 54 | * @throws FileNotFoundException |
| 55 | * if {@code file} cannot be opened for writing. |
| 56 | * @throws SecurityException |
| 57 | * if a {@code SecurityManager} is installed and it denies the |
| 58 | * write request. |
| 59 | * @see java.lang.SecurityManager#checkWrite(FileDescriptor) |
| 60 | */ |
| 61 | public FileOutputStream(File file) throws FileNotFoundException { |
| 62 | this(file, false); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Constructs a new FileOutputStream on the File {@code file}. The |
| 67 | * parameter {@code append} determines whether or not the file is opened and |
| 68 | * appended to or just opened and overwritten. |
| 69 | * |
| 70 | * @param file |
| 71 | * the file to which this stream writes. |
| 72 | * @param append |
| 73 | * indicates whether or not to append to an existing file. |
| 74 | * @throws FileNotFoundException |
| 75 | * if the {@code file} cannot be opened for writing. |
| 76 | * @throws SecurityException |
| 77 | * if a {@code SecurityManager} is installed and it denies the |
| 78 | * write request. |
| 79 | * @see java.lang.SecurityManager#checkWrite(FileDescriptor) |
| 80 | * @see java.lang.SecurityManager#checkWrite(String) |
| 81 | */ |
| 82 | public FileOutputStream(File file, boolean append) |
| 83 | throws FileNotFoundException { |
| 84 | super(); |
| 85 | // SecurityManager security = System.getSecurityManager(); |
| 86 | // if (security != null) { |
| 87 | // security.checkWrite(file.getPath()); |
| 88 | // } |
| 89 | fd = new FileDescriptor(); |
| 90 | fd.descriptor = fileSystem.open(file.properPath(true), |
| 91 | append ? IFileSystem.O_APPEND : IFileSystem.O_WRONLY); |
| 92 | // channel = FileChannelFactory.getFileChannel(this, fd.descriptor, |
nothing calls this directly
no test coverage detected