/** * Constructs a new FileOutputStream on the File {@code file}. The parameter {@code append} * determines whether or not the file is opened and appended to or just opened and overwritten. * * @param file the file to which this stream writes. * @param append indicates whether or not to append to an existing file. * @throws FileNotFoundException if the {@code file} cannot be opened for writing. * @throws SecurityException if a {@code SecurityManager} is installed and it denies the write * request. * @see java.lang.SecurityManager#checkWrite(FileDescriptor) * @see java.lang.SecurityManager#checkWrite(String) */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { super(); if (file.getPath().isEmpty() || file.isDirectory()) { throw new FileNotFoundException(file.getAbsolutePath()); } fd = new FileDescriptor(); fd.readOnly = false; fd.descriptor = open(file.getAbsolutePath(), append); }