changes
authorjjenista <jjenista>
Sat, 7 Mar 2009 00:45:35 +0000 (00:45 +0000)
committerjjenista <jjenista>
Sat, 7 Mar 2009 00:45:35 +0000 (00:45 +0000)
Robust/src/ClassLibrary/SocketInputStream.java

index bc3a65ce04264afd5575c25b4bed56754236884d..f722272611507c723940d1a2efc76673611b6cb8 100644 (file)
@@ -16,6 +16,24 @@ public class SocketInputStream extends InputStream {
     return s.read(b);
   }
 
+  public int readAll(byte[] b) {
+      int offset=read(b);
+      if (offset<0)
+         return offset;
+      int toread=b.length-offset;
+      while(toread>0) {
+         byte t=new byte[toread];
+         int rd=read(t);
+         if (rd<0)
+             return rd;
+         for(int i=0;i<rd;i++)
+             b[i+offset]=t[i];
+         offset+=rd;
+         toread-=rd;
+      }
+      return b.length;
+  }
+
   public void close() {
     s.close();
   }