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

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