This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 117426
Collapse All | Expand All

(-)openide/fs/src/org/openide/filesystems/MIMESupport.java (+30 lines)
Lines 518-523 Link Here
518
            internalClose();
518
            internalClose();
519
        }
519
        }
520
520
521
        @Override
522
        public int read(byte[] b, int off, int blen) throws IOException {
523
            int retval = -1;
524
            if (!eof) {
525
                boolean isCached = (pos + blen < len);
526
                if (isCached) {
527
                    retval = blen;
528
                } else {
529
                    int buflen = Math.max(len, blen);
530
                    buflen = (buflen > 0) ? (buflen * 2) : 256;
531
                    byte[] buf = new byte[buflen];
532
                    if (len > 0) {
533
                        System.arraycopy(buffer, 0, buf, 0, len);
534
                    }
535
                    final int reuiredLen = buflen - blen;
536
                    int c = inputStream.read(buf, len, reuiredLen);
537
                    buffer = buf;
538
                    len += (c > 0) ? c : 0;
539
                    eof = (c < reuiredLen) ? true : false;
540
                    retval = Math.min(c, blen);
541
                }
542
                if (retval > 0) {
543
                    System.arraycopy(buffer, pos, b, off, retval);
544
                    pos += retval;
545
                }                
546
            }
547
            return retval;
548
        }
549
        
550
521
        public int read() throws IOException {
551
        public int read() throws IOException {
522
            if (eof) {
552
            if (eof) {
523
                return -1;
553
                return -1;

Return to bug 117426