home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / io / PrintStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  4.3 KB  |  351 lines

  1. package java.io;
  2.  
  3. public class PrintStream extends FilterOutputStream {
  4.    private boolean autoFlush;
  5.    private boolean trouble;
  6.    private BufferedWriter textOut;
  7.    private OutputStreamWriter charOut;
  8.    private boolean closing;
  9.  
  10.    /** @deprecated */
  11.    public PrintStream(OutputStream var1) {
  12.       this(var1, false);
  13.    }
  14.  
  15.    /** @deprecated */
  16.    public PrintStream(OutputStream var1, boolean var2) {
  17.       super(var1);
  18.       this.autoFlush = false;
  19.       this.trouble = false;
  20.       this.closing = false;
  21.       this.autoFlush = var2;
  22.       this.charOut = new OutputStreamWriter(this);
  23.       this.textOut = new BufferedWriter(this.charOut);
  24.    }
  25.  
  26.    private void ensureOpen() throws IOException {
  27.       if (super.out == null) {
  28.          throw new IOException("Stream closed");
  29.       }
  30.    }
  31.  
  32.    public void flush() {
  33.       synchronized(this){}
  34.  
  35.       try {
  36.          try {
  37.             this.ensureOpen();
  38.             super.out.flush();
  39.          } catch (IOException var4) {
  40.             this.trouble = true;
  41.          }
  42.       } catch (Throwable var5) {
  43.          throw var5;
  44.       }
  45.  
  46.    }
  47.  
  48.    public void close() {
  49.       synchronized(this){}
  50.  
  51.       try {
  52.          if (!this.closing) {
  53.             this.closing = true;
  54.  
  55.             try {
  56.                this.textOut.close();
  57.                super.out.close();
  58.             } catch (IOException var4) {
  59.                this.trouble = true;
  60.             }
  61.  
  62.             this.textOut = null;
  63.             this.charOut = null;
  64.             super.out = null;
  65.          }
  66.       } catch (Throwable var5) {
  67.          throw var5;
  68.       }
  69.  
  70.    }
  71.  
  72.    public boolean checkError() {
  73.       if (super.out != null) {
  74.          this.flush();
  75.       }
  76.  
  77.       return this.trouble;
  78.    }
  79.  
  80.    protected void setError() {
  81.       this.trouble = true;
  82.    }
  83.  
  84.    public void write(int var1) {
  85.       try {
  86.          synchronized(this){}
  87.  
  88.          try {
  89.             this.ensureOpen();
  90.             super.out.write(var1);
  91.             if (var1 == 10 && this.autoFlush) {
  92.                super.out.flush();
  93.             }
  94.          } catch (Throwable var6) {
  95.             throw var6;
  96.          }
  97.  
  98.       } catch (InterruptedIOException var7) {
  99.          Thread.currentThread().interrupt();
  100.       } catch (IOException var8) {
  101.          this.trouble = true;
  102.       }
  103.    }
  104.  
  105.    public void write(byte[] var1, int var2, int var3) {
  106.       try {
  107.          synchronized(this){}
  108.  
  109.          try {
  110.             this.ensureOpen();
  111.             super.out.write(var1, var2, var3);
  112.             if (this.autoFlush) {
  113.                super.out.flush();
  114.             }
  115.          } catch (Throwable var8) {
  116.             throw var8;
  117.          }
  118.  
  119.       } catch (InterruptedIOException var9) {
  120.          Thread.currentThread().interrupt();
  121.       } catch (IOException var10) {
  122.          this.trouble = true;
  123.       }
  124.    }
  125.  
  126.    private void write(char[] var1) {
  127.       try {
  128.          synchronized(this){}
  129.  
  130.          try {
  131.             this.ensureOpen();
  132.             this.textOut.write(var1);
  133.             this.textOut.flushBuffer();
  134.             this.charOut.flushBuffer();
  135.             if (this.autoFlush) {
  136.                for(int var4 = 0; var4 < var1.length; ++var4) {
  137.                   if (var1[var4] == '\n') {
  138.                      super.out.flush();
  139.                   }
  140.                }
  141.             }
  142.          } catch (Throwable var8) {
  143.             throw var8;
  144.          }
  145.  
  146.       } catch (InterruptedIOException var9) {
  147.          Thread.currentThread().interrupt();
  148.       } catch (IOException var10) {
  149.          this.trouble = true;
  150.       }
  151.    }
  152.  
  153.    private void write(String var1) {
  154.       try {
  155.          synchronized(this){}
  156.  
  157.          try {
  158.             this.ensureOpen();
  159.             this.textOut.write(var1);
  160.             this.textOut.flushBuffer();
  161.             this.charOut.flushBuffer();
  162.             if (this.autoFlush && var1.indexOf(10) >= 0) {
  163.                super.out.flush();
  164.             }
  165.          } catch (Throwable var6) {
  166.             throw var6;
  167.          }
  168.  
  169.       } catch (InterruptedIOException var7) {
  170.          Thread.currentThread().interrupt();
  171.       } catch (IOException var8) {
  172.          this.trouble = true;
  173.       }
  174.    }
  175.  
  176.    private void newLine() {
  177.       try {
  178.          synchronized(this){}
  179.  
  180.          try {
  181.             this.ensureOpen();
  182.             this.textOut.newLine();
  183.             this.textOut.flushBuffer();
  184.             this.charOut.flushBuffer();
  185.             if (this.autoFlush) {
  186.                super.out.flush();
  187.             }
  188.          } catch (Throwable var5) {
  189.             throw var5;
  190.          }
  191.  
  192.       } catch (InterruptedIOException var6) {
  193.          Thread.currentThread().interrupt();
  194.       } catch (IOException var7) {
  195.          this.trouble = true;
  196.       }
  197.    }
  198.  
  199.    public void print(boolean var1) {
  200.       this.write(var1 ? "true" : "false");
  201.    }
  202.  
  203.    public void print(char var1) {
  204.       this.write(String.valueOf(var1));
  205.    }
  206.  
  207.    public void print(int var1) {
  208.       this.write(String.valueOf(var1));
  209.    }
  210.  
  211.    public void print(long var1) {
  212.       this.write(String.valueOf(var1));
  213.    }
  214.  
  215.    public void print(float var1) {
  216.       this.write(String.valueOf(var1));
  217.    }
  218.  
  219.    public void print(double var1) {
  220.       this.write(String.valueOf(var1));
  221.    }
  222.  
  223.    public void print(char[] var1) {
  224.       this.write(var1);
  225.    }
  226.  
  227.    public void print(String var1) {
  228.       if (var1 == null) {
  229.          var1 = "null";
  230.       }
  231.  
  232.       this.write(var1);
  233.    }
  234.  
  235.    public void print(Object var1) {
  236.       this.write(String.valueOf(var1));
  237.    }
  238.  
  239.    public void println() {
  240.       this.newLine();
  241.    }
  242.  
  243.    public void println(boolean var1) {
  244.       synchronized(this){}
  245.  
  246.       try {
  247.          this.print(var1);
  248.          this.newLine();
  249.       } catch (Throwable var4) {
  250.          throw var4;
  251.       }
  252.  
  253.    }
  254.  
  255.    public void println(char var1) {
  256.       synchronized(this){}
  257.  
  258.       try {
  259.          this.print(var1);
  260.          this.newLine();
  261.       } catch (Throwable var4) {
  262.          throw var4;
  263.       }
  264.  
  265.    }
  266.  
  267.    public void println(int var1) {
  268.       synchronized(this){}
  269.  
  270.       try {
  271.          this.print(var1);
  272.          this.newLine();
  273.       } catch (Throwable var4) {
  274.          throw var4;
  275.       }
  276.  
  277.    }
  278.  
  279.    public void println(long var1) {
  280.       synchronized(this){}
  281.  
  282.       try {
  283.          this.print(var1);
  284.          this.newLine();
  285.       } catch (Throwable var5) {
  286.          throw var5;
  287.       }
  288.  
  289.    }
  290.  
  291.    public void println(float var1) {
  292.       synchronized(this){}
  293.  
  294.       try {
  295.          this.print(var1);
  296.          this.newLine();
  297.       } catch (Throwable var4) {
  298.          throw var4;
  299.       }
  300.  
  301.    }
  302.  
  303.    public void println(double var1) {
  304.       synchronized(this){}
  305.  
  306.       try {
  307.          this.print(var1);
  308.          this.newLine();
  309.       } catch (Throwable var5) {
  310.          throw var5;
  311.       }
  312.  
  313.    }
  314.  
  315.    public void println(char[] var1) {
  316.       synchronized(this){}
  317.  
  318.       try {
  319.          this.print(var1);
  320.          this.newLine();
  321.       } catch (Throwable var4) {
  322.          throw var4;
  323.       }
  324.  
  325.    }
  326.  
  327.    public void println(String var1) {
  328.       synchronized(this){}
  329.  
  330.       try {
  331.          this.print(var1);
  332.          this.newLine();
  333.       } catch (Throwable var4) {
  334.          throw var4;
  335.       }
  336.  
  337.    }
  338.  
  339.    public void println(Object var1) {
  340.       synchronized(this){}
  341.  
  342.       try {
  343.          this.print(var1);
  344.          this.newLine();
  345.       } catch (Throwable var4) {
  346.          throw var4;
  347.       }
  348.  
  349.    }
  350. }
  351.