src/java.base/share/classes/java/util/jar/Manifest.java

Print this page




 364          * is reached. Returns the number of bytes read.
 365          */
 366         public int readLine(byte[] b, int off, int len) throws IOException {
 367             byte[] tbuf = this.buf;
 368             int total = 0;
 369             while (total < len) {
 370                 int avail = count - pos;
 371                 if (avail <= 0) {
 372                     fill();
 373                     avail = count - pos;
 374                     if (avail <= 0) {
 375                         return -1;
 376                     }
 377                 }
 378                 int n = len - total;
 379                 if (n > avail) {
 380                     n = avail;
 381                 }
 382                 int tpos = pos;
 383                 int maxpos = tpos + n;
 384                 while (tpos < maxpos && tbuf[tpos++] != '\n') ;





 385                 n = tpos - pos;
 386                 System.arraycopy(tbuf, pos, b, off, n);
 387                 off += n;
 388                 total += n;
 389                 pos = tpos;
 390                 if (tbuf[tpos-1] == '\n') {
 391                     break;
 392                 }
 393             }
 394             return total;
 395         }
 396 
 397         public byte peek() throws IOException {
 398             if (pos == count)
 399                 fill();
 400             if (pos == count)
 401                 return -1; // nothing left in buffer
 402             return buf[pos];
 403         }
 404 
 405         public int readLine(byte[] b) throws IOException {
 406             return readLine(b, 0, b.length);
 407         }
 408 
 409         public long skip(long n) throws IOException {
 410             if (n <= 0) {




 364          * is reached. Returns the number of bytes read.
 365          */
 366         public int readLine(byte[] b, int off, int len) throws IOException {
 367             byte[] tbuf = this.buf;
 368             int total = 0;
 369             while (total < len) {
 370                 int avail = count - pos;
 371                 if (avail <= 0) {
 372                     fill();
 373                     avail = count - pos;
 374                     if (avail <= 0) {
 375                         return -1;
 376                     }
 377                 }
 378                 int n = len - total;
 379                 if (n > avail) {
 380                     n = avail;
 381                 }
 382                 int tpos = pos;
 383                 int maxpos = tpos + n;
 384                 byte c = 0;
 385                 // jar.spec.newline: CRLF | LF | CR (not followed by LF)
 386                 while (tpos < maxpos && (c = tbuf[tpos++]) != '\n' && c != '\r') ;
 387                 if (tpos < maxpos && c == '\r' && tbuf[tpos] == '\n') {
 388                     tpos++;
 389                 }
 390                 n = tpos - pos;
 391                 System.arraycopy(tbuf, pos, b, off, n);
 392                 off += n;
 393                 total += n;
 394                 pos = tpos;
 395                 if ((c = tbuf[tpos-1]) == '\n' || c == '\r') {
 396                     break;
 397                 }
 398             }
 399             return total;
 400         }
 401 
 402         public byte peek() throws IOException {
 403             if (pos == count)
 404                 fill();
 405             if (pos == count)
 406                 return -1; // nothing left in buffer
 407             return buf[pos];
 408         }
 409 
 410         public int readLine(byte[] b) throws IOException {
 411             return readLine(b, 0, b.length);
 412         }
 413 
 414         public long skip(long n) throws IOException {
 415             if (n <= 0) {