| 1 | // FileOutputStream.java - Write bytes to a file.
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 1998, 1999, 2001 Free Software Foundation
|
|---|
| 4 |
|
|---|
| 5 | This file is part of libgcj.
|
|---|
| 6 |
|
|---|
| 7 | This software is copyrighted work licensed under the terms of the
|
|---|
| 8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|---|
| 9 | details. */
|
|---|
| 10 |
|
|---|
| 11 | package java.io;
|
|---|
| 12 |
|
|---|
| 13 | import java.nio.channels.FileChannel;
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * @author Tom Tromey <[email protected]>
|
|---|
| 17 | * @date September 24, 1998
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
|
|---|
| 21 | * "The Java Language Specification", ISBN 0-201-63451-1
|
|---|
| 22 | * Status: Complete to version 1.1.
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | public class FileOutputStream extends OutputStream
|
|---|
| 26 | {
|
|---|
| 27 | public FileOutputStream (String path, boolean append)
|
|---|
| 28 | throws SecurityException, FileNotFoundException
|
|---|
| 29 | {
|
|---|
| 30 | SecurityManager s = System.getSecurityManager();
|
|---|
| 31 | if (s != null)
|
|---|
| 32 | s.checkWrite(path);
|
|---|
| 33 | fd = new FileDescriptor (path, (append
|
|---|
| 34 | ? FileDescriptor.APPEND
|
|---|
| 35 | : FileDescriptor.WRITE));
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | public FileOutputStream (String path)
|
|---|
| 39 | throws SecurityException, FileNotFoundException
|
|---|
| 40 | {
|
|---|
| 41 | this (path, false);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | public FileOutputStream (File file)
|
|---|
| 45 | throws SecurityException, FileNotFoundException
|
|---|
| 46 | {
|
|---|
| 47 | this (file.getPath(), false);
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | public FileOutputStream (FileDescriptor fdObj)
|
|---|
| 51 | throws SecurityException
|
|---|
| 52 | {
|
|---|
| 53 | SecurityManager s = System.getSecurityManager();
|
|---|
| 54 | if (s != null)
|
|---|
| 55 | s.checkWrite(fdObj);
|
|---|
| 56 | fd = fdObj;
|
|---|
|
|---|