/[classpath]/inetlib/source/gnu/inet/ftp/BlockOutputStream.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/ftp/BlockOutputStream.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dog, Sun Oct 19 16:16:49 2003 UTC revision 1.3 by dog, Mon Nov 10 12:29:56 2003 UTC
# Line 40  import java.io.OutputStream; Line 40  import java.io.OutputStream;
40  class BlockOutputStream extends DTPOutputStream  class BlockOutputStream extends DTPOutputStream
41  {  {
42    
43    static final byte RECORD = -128;      // 0x80      static final byte RECORD = -128;      // 0x80
44    static final byte EOF = 64;   // 0x40      static final byte EOF = 64;   // 0x40
45        
46      BlockOutputStream(DTP dtp, OutputStream out)      BlockOutputStream(DTP dtp, OutputStream out)
   {  
     super(dtp, out);  
   }  
   
   public void write(int c) throws IOException  
   {  
     if (transferComplete)  
       return;  
     byte[] buf = new byte[]  
47      {      {
48        RECORD,                   /* record descriptor */          super(dtp, out);
49          0x00, 0x01,             /* one byte */      }
50          (byte) c                /* the byte */      
51      };      public void write(int c) throws IOException
52      super.write(buf, 0, 4);      {
53    }          if (transferComplete)
54                return;
55    public void write(byte[]b) throws IOException          byte[] buf = new byte[]
56    {          {
57      write(b, 0, b.length);              RECORD,                   /* record descriptor */
58    }              0x00, 0x01,             /* one byte */
59                (byte) c                /* the byte */
60    public void write(byte[]b, int off, int len) throws IOException          };
61    {          out.write(buf, 0, 4);
62      if (transferComplete)      }
       return;  
     byte[] buf = new byte[len + 3];  
     buf[0] = RECORD;            /* record descriptor */  
     buf[1] = (byte) ((len & 0x00ff) >> 8);      /* high byte of bytecount */  
     buf[2] = (byte) (len & 0xff00);     /* low byte of bytecount */  
     System.arraycopy(b, off, buf, 3, len);  
     super.write(buf, 0, len);  
   }  
63    
64    public void close() throws IOException      public void write(byte[] b) throws IOException
65    {      {
66      byte[] buf = new byte[]          write(b, 0, b.length);
67        }
68        
69        public void write(byte[] b, int off, int len) throws IOException
70        {
71            if (transferComplete)
72                return;
73            byte[] buf = new byte[len + 3];
74            buf[0] = RECORD;            /* record descriptor */
75            buf[1] = (byte) ((len & 0x00ff) >> 8);      /* high byte of bytecount */
76            buf[2] = (byte) (len & 0xff00);     /* low byte of bytecount */
77            System.arraycopy(b, off, buf, 3, len);
78            out.write(buf, 0, len);
79        }
80        
81        public void close() throws IOException
82      {      {
83        EOF,                      /* eof descriptor */          byte[] buf = new byte[]
84          0x00, 0x00              /* no bytes */          {
85      };              EOF,                      /* eof descriptor */
86      super.write(buf, 0, 3);              0x00, 0x00              /* no bytes */
87      super.close();          };
88    }          out.write(buf, 0, 3);
89            super.close();
90        }
91    
92  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26