home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / io / PrintStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  3.8 KB  |  168 lines

  1. package java.io;
  2.  
  3. public class PrintStream extends FilterOutputStream {
  4.    private boolean autoflush;
  5.    private boolean trouble;
  6.  
  7.    public PrintStream(OutputStream out) {
  8.       this(out, false);
  9.       this.trouble = false;
  10.    }
  11.  
  12.    public PrintStream(OutputStream out, boolean autoflush) {
  13.       super(out);
  14.       this.autoflush = autoflush;
  15.       this.trouble = false;
  16.    }
  17.  
  18.    public void write(int b) {
  19.       try {
  20.          super.out.write(b);
  21.          if (this.autoflush && b == 10) {
  22.             super.out.flush();
  23.             return;
  24.          }
  25.       } catch (InterruptedIOException var2) {
  26.          Thread.currentThread().interrupt();
  27.          return;
  28.       } catch (IOException var3) {
  29.          this.trouble = true;
  30.       }
  31.  
  32.    }
  33.  
  34.    public void write(byte[] b, int off, int len) {
  35.       try {
  36.          super.out.write(b, off, len);
  37.          if (this.autoflush) {
  38.             super.out.flush();
  39.             return;
  40.          }
  41.       } catch (InterruptedIOException var4) {
  42.          Thread.currentThread().interrupt();
  43.          return;
  44.       } catch (IOException var5) {
  45.          this.trouble = true;
  46.       }
  47.  
  48.    }
  49.  
  50.    public void flush() {
  51.       try {
  52.          super.flush();
  53.       } catch (IOException var1) {
  54.          this.trouble = true;
  55.       }
  56.    }
  57.  
  58.    public void close() {
  59.       try {
  60.          super.close();
  61.       } catch (IOException var1) {
  62.          this.trouble = true;
  63.       }
  64.    }
  65.  
  66.    public boolean checkError() {
  67.       this.flush();
  68.       return this.trouble;
  69.    }
  70.  
  71.    public void print(Object obj) {
  72.       this.print(String.valueOf(obj));
  73.    }
  74.  
  75.    public synchronized void print(String s) {
  76.       if (s == null) {
  77.          s = "null";
  78.       }
  79.  
  80.       int len = s.length();
  81.  
  82.       for(int i = 0; i < len; ++i) {
  83.          this.write(s.charAt(i));
  84.       }
  85.  
  86.    }
  87.  
  88.    public synchronized void print(char[] s) {
  89.       for(int i = 0; i < s.length; ++i) {
  90.          this.write(s[i]);
  91.       }
  92.  
  93.    }
  94.  
  95.    public void print(char c) {
  96.       this.print(String.valueOf(c));
  97.    }
  98.  
  99.    public void print(int i) {
  100.       this.print(String.valueOf(i));
  101.    }
  102.  
  103.    public void print(long l) {
  104.       this.print(String.valueOf(l));
  105.    }
  106.  
  107.    public void print(float f) {
  108.       this.print(String.valueOf(f));
  109.    }
  110.  
  111.    public void print(double d) {
  112.       this.print(String.valueOf(d));
  113.    }
  114.  
  115.    public void print(boolean b) {
  116.       this.print(b ? "true" : "false");
  117.    }
  118.  
  119.    public void println() {
  120.       this.write(10);
  121.    }
  122.  
  123.    public synchronized void println(Object obj) {
  124.       this.print(obj);
  125.       this.write(10);
  126.    }
  127.  
  128.    public synchronized void println(String s) {
  129.       this.print(s);
  130.       this.write(10);
  131.    }
  132.  
  133.    public synchronized void println(char[] s) {
  134.       this.print(s);
  135.       this.write(10);
  136.    }
  137.  
  138.    public synchronized void println(char c) {
  139.       this.print(c);
  140.       this.write(10);
  141.    }
  142.  
  143.    public synchronized void println(int i) {
  144.       this.print(i);
  145.       this.write(10);
  146.    }
  147.  
  148.    public synchronized void println(long l) {
  149.       this.print(l);
  150.       this.write(10);
  151.    }
  152.  
  153.    public synchronized void println(float f) {
  154.       this.print(f);
  155.       this.write(10);
  156.    }
  157.  
  158.    public synchronized void println(double d) {
  159.       this.print(d);
  160.       this.write(10);
  161.    }
  162.  
  163.    public synchronized void println(boolean b) {
  164.       this.print(b);
  165.       this.write(10);
  166.    }
  167. }
  168.