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

  1. package sun.net.smtp;
  2.  
  3. import java.io.IOException;
  4. import java.io.OutputStream;
  5. import java.io.PrintStream;
  6.  
  7. class SmtpPrintStream extends PrintStream {
  8.    private SmtpClient target;
  9.    private int lastc = 10;
  10.  
  11.    SmtpPrintStream(OutputStream var1, SmtpClient var2) {
  12.       super(var1);
  13.       this.target = var2;
  14.    }
  15.  
  16.    public void close() {
  17.       if (this.target != null) {
  18.          if (this.lastc != 10) {
  19.             this.write(13);
  20.             this.write(10);
  21.          }
  22.  
  23.          try {
  24.             this.target.issueCommand(".\r\n", 250);
  25.             this.target.message = null;
  26.             super.out = null;
  27.             this.target = null;
  28.          } catch (IOException var1) {
  29.          }
  30.       }
  31.    }
  32.  
  33.    public void write(int var1) {
  34.       try {
  35.          if (this.lastc == 10 && var1 == 46) {
  36.             super.out.write(46);
  37.          }
  38.  
  39.          if (var1 == 10) {
  40.             super.out.write(13);
  41.          }
  42.  
  43.          super.out.write(var1);
  44.          this.lastc = var1;
  45.       } catch (IOException var2) {
  46.       }
  47.    }
  48.  
  49.    public void write(byte[] var1, int var2, int var3) {
  50.       try {
  51.          int var4 = this.lastc;
  52.  
  53.          while(true) {
  54.             --var3;
  55.             if (var3 < 0) {
  56.                this.lastc = var4;
  57.                return;
  58.             }
  59.  
  60.             byte var5 = var1[var2++];
  61.             if (var4 == 10 && var5 == 46) {
  62.                super.out.write(46);
  63.             }
  64.  
  65.             if (var5 == 10) {
  66.                super.out.write(13);
  67.             }
  68.  
  69.             super.out.write(var5);
  70.             var4 = var5;
  71.          }
  72.       } catch (IOException var6) {
  73.       }
  74.    }
  75.  
  76.    public void print(String var1) {
  77.       int var2 = var1.length();
  78.  
  79.       for(int var3 = 0; var3 < var2; ++var3) {
  80.          this.write(var1.charAt(var3));
  81.       }
  82.  
  83.    }
  84. }
  85.