home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / io / PrintWriter.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.5 KB  |  268 lines

  1. package java.io;
  2.  
  3. import java.security.AccessController;
  4. import sun.security.action.GetPropertyAction;
  5.  
  6. public class PrintWriter extends Writer {
  7.    protected Writer out;
  8.    private boolean autoFlush;
  9.    private boolean trouble;
  10.    private String lineSeparator;
  11.  
  12.    public PrintWriter(Writer var1) {
  13.       this(var1, false);
  14.    }
  15.  
  16.    public PrintWriter(Writer var1, boolean var2) {
  17.       super(var1);
  18.       this.autoFlush = false;
  19.       this.trouble = false;
  20.       this.out = var1;
  21.       this.autoFlush = var2;
  22.       this.lineSeparator = (String)AccessController.doPrivileged(new GetPropertyAction("line.separator"));
  23.    }
  24.  
  25.    public PrintWriter(OutputStream var1) {
  26.       this(var1, false);
  27.    }
  28.  
  29.    public PrintWriter(OutputStream var1, boolean var2) {
  30.       this((Writer)(new BufferedWriter(new OutputStreamWriter(var1))), var2);
  31.    }
  32.  
  33.    private void ensureOpen() throws IOException {
  34.       if (this.out == null) {
  35.          throw new IOException("Stream closed");
  36.       }
  37.    }
  38.  
  39.    public void flush() {
  40.       try {
  41.          Object var1 = super.lock;
  42.          synchronized(var1) {
  43.             this.ensureOpen();
  44.             this.out.flush();
  45.          }
  46.       } catch (IOException var4) {
  47.          this.trouble = true;
  48.       }
  49.  
  50.    }
  51.  
  52.    public void close() {
  53.       try {
  54.          Object var1 = super.lock;
  55.          synchronized(var1) {
  56.             if (this.out == null) {
  57.                return;
  58.             }
  59.  
  60.             this.out.close();
  61.             this.out = null;
  62.          }
  63.       } catch (IOException var4) {
  64.          this.trouble = true;
  65.       }
  66.  
  67.    }
  68.  
  69.    public boolean checkError() {
  70.       if (this.out != null) {
  71.          this.flush();
  72.       }
  73.  
  74.       return this.trouble;
  75.    }
  76.  
  77.    protected void setError() {
  78.       this.trouble = true;
  79.    }
  80.  
  81.    public void write(int var1) {
  82.       try {
  83.          Object var2 = super.lock;
  84.          synchronized(var2) {
  85.             this.ensureOpen();
  86.             this.out.write(var1);
  87.          }
  88.       } catch (InterruptedIOException var5) {
  89.          Thread.currentThread().interrupt();
  90.       } catch (IOException var6) {
  91.          this.trouble = true;
  92.       }
  93.  
  94.    }
  95.  
  96.    public void write(char[] var1, int var2, int var3) {
  97.       try {
  98.          Object var4 = super.lock;
  99.          synchronized(var4) {
  100.             this.ensureOpen();
  101.             this.out.write(var1, var2, var3);
  102.          }
  103.       } catch (InterruptedIOException var7) {
  104.          Thread.currentThread().interrupt();
  105.       } catch (IOException var8) {
  106.          this.trouble = true;
  107.       }
  108.  
  109.    }
  110.  
  111.    public void write(char[] var1) {
  112.       this.write((char[])var1, 0, var1.length);
  113.    }
  114.  
  115.    public void write(String var1, int var2, int var3) {
  116.       try {
  117.          Object var4 = super.lock;
  118.          synchronized(var4) {
  119.             this.ensureOpen();
  120.             this.out.write(var1, var2, var3);
  121.          }
  122.       } catch (InterruptedIOException var7) {
  123.          Thread.currentThread().interrupt();
  124.       } catch (IOException var8) {
  125.          this.trouble = true;
  126.       }
  127.  
  128.    }
  129.  
  130.    public void write(String var1) {
  131.       this.write((String)var1, 0, var1.length());
  132.    }
  133.  
  134.    private void newLine() {
  135.       try {
  136.          Object var1 = super.lock;
  137.          synchronized(var1) {
  138.             this.ensureOpen();
  139.             this.out.write(this.lineSeparator);
  140.             if (this.autoFlush) {
  141.                this.out.flush();
  142.             }
  143.          }
  144.       } catch (InterruptedIOException var4) {
  145.          Thread.currentThread().interrupt();
  146.       } catch (IOException var5) {
  147.          this.trouble = true;
  148.       }
  149.  
  150.    }
  151.  
  152.    public void print(boolean var1) {
  153.       this.write(var1 ? "true" : "false");
  154.    }
  155.  
  156.    public void print(char var1) {
  157.       this.write(String.valueOf(var1));
  158.    }
  159.  
  160.    public void print(int var1) {
  161.       this.write(String.valueOf(var1));
  162.    }
  163.  
  164.    public void print(long var1) {
  165.       this.write(String.valueOf(var1));
  166.    }
  167.  
  168.    public void print(float var1) {
  169.       this.write(String.valueOf(var1));
  170.    }
  171.  
  172.    public void print(double var1) {
  173.       this.write(String.valueOf(var1));
  174.    }
  175.  
  176.    public void print(char[] var1) {
  177.       this.write(var1);
  178.    }
  179.  
  180.    public void print(String var1) {
  181.       if (var1 == null) {
  182.          var1 = "null";
  183.       }
  184.  
  185.       this.write(var1);
  186.    }
  187.  
  188.    public void print(Object var1) {
  189.       this.write(String.valueOf(var1));
  190.    }
  191.  
  192.    public void println() {
  193.       this.newLine();
  194.    }
  195.  
  196.    public void println(boolean var1) {
  197.       Object var2 = super.lock;
  198.       synchronized(var2) {
  199.          this.print(var1);
  200.          this.println();
  201.       }
  202.    }
  203.  
  204.    public void println(char var1) {
  205.       Object var2 = super.lock;
  206.       synchronized(var2) {
  207.          this.print(var1);
  208.          this.println();
  209.       }
  210.    }
  211.  
  212.    public void println(int var1) {
  213.       Object var2 = super.lock;
  214.       synchronized(var2) {
  215.          this.print(var1);
  216.          this.println();
  217.       }
  218.    }
  219.  
  220.    public void println(long var1) {
  221.       Object var3 = super.lock;
  222.       synchronized(var3) {
  223.          this.print(var1);
  224.          this.println();
  225.       }
  226.    }
  227.  
  228.    public void println(float var1) {
  229.       Object var2 = super.lock;
  230.       synchronized(var2) {
  231.          this.print(var1);
  232.          this.println();
  233.       }
  234.    }
  235.  
  236.    public void println(double var1) {
  237.       Object var3 = super.lock;
  238.       synchronized(var3) {
  239.          this.print(var1);
  240.          this.println();
  241.       }
  242.    }
  243.  
  244.    public void println(char[] var1) {
  245.       Object var2 = super.lock;
  246.       synchronized(var2) {
  247.          this.print(var1);
  248.          this.println();
  249.       }
  250.    }
  251.  
  252.    public void println(String var1) {
  253.       Object var2 = super.lock;
  254.       synchronized(var2) {
  255.          this.print(var1);
  256.          this.println();
  257.       }
  258.    }
  259.  
  260.    public void println(Object var1) {
  261.       Object var2 = super.lock;
  262.       synchronized(var2) {
  263.          this.print(var1);
  264.          this.println();
  265.       }
  266.    }
  267. }
  268.