Logo Search packages:      
Sourcecode: jlha-utils version File versions  Download package

int org::jlhafrontend::JLHAFrontEnd::transferTo ( InputStream  in,
OutputStream  out,
long[]  ent 
) [inline, private]

Transfer an InputStream to an OutputStream

Parameters:
in the input stream
out the output stream
ent the distribution array
Returns:
number of blocks (8k bytes) copied

Definition at line 200 of file JLHAFrontEnd.java.

References mylogger.

                                                                         {
      int i,j,bufRead,k;
      byte[] buf = new byte[1024*8];
      for (j=0 ; j<256 ; j++) {
          ent[j]=0;
        }
      for (i=0; true; i++) {
          try {
            bufRead=in.read(buf);
          } catch (Exception e) {
            mylogger.severe("read from in "+e.toString());
            break;
          }
          if (bufRead<=0) break;
          for (j=0 ; j<bufRead ; j++) {
              k=buf[j];
              while (k<0) {
                  k+=256;
                }
                k = k%256;
                ent[k]++;
            }
          try {
            out.write(buf,0,bufRead);
          } catch (Exception e) {
            mylogger.severe("write to out "+e.toString());
            break;
          }
      }
      return i;
    }


Generated by  Doxygen 1.6.0   Back to index