home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / io / FileOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.0 KB  |  128 lines

  1. package java.io;
  2.  
  3. import java.nio.channels.FileChannel;
  4. import sun.nio.ch.FileChannelImpl;
  5.  
  6. public class FileOutputStream extends OutputStream {
  7.    // $FF: renamed from: fd java.io.FileDescriptor
  8.    private FileDescriptor field_0;
  9.    private FileChannel channel;
  10.    private boolean append;
  11.  
  12.    public FileOutputStream(String var1) throws FileNotFoundException {
  13.       this(var1 != null ? new File(var1) : null, false);
  14.    }
  15.  
  16.    public FileOutputStream(String var1, boolean var2) throws FileNotFoundException {
  17.       this(var1 != null ? new File(var1) : null, var2);
  18.    }
  19.  
  20.    public FileOutputStream(File var1) throws FileNotFoundException {
  21.       this(var1, false);
  22.    }
  23.  
  24.    public FileOutputStream(File var1, boolean var2) throws FileNotFoundException {
  25.       this.channel = null;
  26.       this.append = false;
  27.       String var3 = var1 != null ? var1.getPath() : null;
  28.       SecurityManager var4 = System.getSecurityManager();
  29.       if (var4 != null) {
  30.          var4.checkWrite(var3);
  31.       }
  32.  
  33.       if (var3 == null) {
  34.          throw new NullPointerException();
  35.       } else {
  36.          this.field_0 = new FileDescriptor();
  37.          this.append = var2;
  38.          if (var2) {
  39.             this.openAppend(var3);
  40.          } else {
  41.             this.open(var3);
  42.          }
  43.  
  44.       }
  45.    }
  46.  
  47.    public FileOutputStream(FileDescriptor var1) {
  48.       this.channel = null;
  49.       this.append = false;
  50.       SecurityManager var2 = System.getSecurityManager();
  51.       if (var1 == null) {
  52.          throw new NullPointerException();
  53.       } else {
  54.          if (var2 != null) {
  55.             var2.checkWrite(var1);
  56.          }
  57.  
  58.          this.field_0 = var1;
  59.       }
  60.    }
  61.  
  62.    private native void open(String var1) throws FileNotFoundException;
  63.  
  64.    private native void openAppend(String var1) throws FileNotFoundException;
  65.  
  66.    public native void write(int var1) throws IOException;
  67.  
  68.    private native void writeBytes(byte[] var1, int var2, int var3) throws IOException;
  69.  
  70.    public void write(byte[] var1) throws IOException {
  71.       this.writeBytes(var1, 0, var1.length);
  72.    }
  73.  
  74.    public void write(byte[] var1, int var2, int var3) throws IOException {
  75.       this.writeBytes(var1, var2, var3);
  76.    }
  77.  
  78.    public void close() throws IOException {
  79.       if (this.channel != null) {
  80.          this.channel.close();
  81.       }
  82.  
  83.       this.close0();
  84.    }
  85.  
  86.    public final FileDescriptor getFD() throws IOException {
  87.       if (this.field_0 != null) {
  88.          return this.field_0;
  89.       } else {
  90.          throw new IOException();
  91.       }
  92.    }
  93.  
  94.    public FileChannel getChannel() {
  95.       synchronized(this) {
  96.          if (this.channel == null) {
  97.             this.channel = FileChannelImpl.open(this.field_0, false, true, this, this.append);
  98.          }
  99.  
  100.          return this.channel;
  101.       }
  102.    }
  103.  
  104.    protected void finalize() throws IOException {
  105.       if (this.field_0 != null) {
  106.          FileDescriptor var10001 = this.field_0;
  107.          if (this.field_0 != FileDescriptor.out) {
  108.             var10001 = this.field_0;
  109.             if (this.field_0 != FileDescriptor.err) {
  110.                this.close();
  111.                return;
  112.             }
  113.          }
  114.  
  115.          this.flush();
  116.       }
  117.  
  118.    }
  119.  
  120.    private native void close0() throws IOException;
  121.  
  122.    private static native void initIDs();
  123.  
  124.    static {
  125.       initIDs();
  126.    }
  127. }
  128.