flip() public méthode

public flip ( ) : Buf
Résultat Buf
Exemple #1
0
 public virtual long pipe(OutStream output, Long toPipe, bool cls)
 {
     try
     {
         long bufSize = FanInt.Chunk.longValue();
         Buf  buf     = Buf.make(bufSize);
         long total   = 0;
         if (toPipe == null)
         {
             while (true)
             {
                 Long n = readBuf(buf.clear(), bufSize);
                 if (n == null)
                 {
                     break;
                 }
                 output.writeBuf(buf.flip(), buf.remaining());
                 total += n.longValue();
             }
         }
         else
         {
             long toPipeVal = toPipe.longValue();
             while (total < toPipeVal)
             {
                 if (toPipeVal - total < bufSize)
                 {
                     bufSize = toPipeVal - total;
                 }
                 Long n = readBuf(buf.clear(), bufSize);
                 if (n == null)
                 {
                     throw IOErr.make("Unexpected end of stream").val;
                 }
                 output.writeBuf(buf.flip(), buf.remaining());
                 total += n.longValue();
             }
         }
         return(total);
     }
     finally
     {
         if (cls)
         {
             close();
         }
     }
 }
Exemple #2
0
 public virtual Buf readAllBuf()
 {
     try
     {
         long size = FanInt.Chunk.longValue();
         Buf  buf  = Buf.make(size);
         while (readBuf(buf, size) != null)
         {
             ;
         }
         buf.flip();
         return(buf);
     }
     finally
     {
         try { close(); } catch (System.Exception e) { Err.dumpStack(e); }
     }
 }
Exemple #3
0
        public virtual Buf readBufFully(Buf buf, long n)
        {
            if (buf == null)
            {
                buf = Buf.make(n);
            }

            long total = n;
            long got   = 0;

            while (got < total)
            {
                Long r = readBuf(buf, total - got);
                if (r == null || r.longValue() == 0)
                {
                    throw IOErr.make("Unexpected end of stream").val;
                }
                got += r.longValue();
            }

            buf.flip();
            return(buf);
        }
Exemple #4
0
        public virtual Buf readBufFully(Buf buf, long n)
        {
            if (buf == null) buf = Buf.make(n);

              long total = n;
              long got = 0;
              while (got < total)
              {
            Long r = readBuf(buf, total-got);
            if (r == null || r.longValue() == 0) throw IOErr.make("Unexpected end of stream").val;
            got += r.longValue();
              }

              buf.flip();
              return buf;
        }