View | Details | Raw Unified | Return to bug 570670 | Differences between
and this patch

Collapse All | Expand All

(-)a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/io/SimpleBufferedRandomAccessInputStream.java (-4 / +7 lines)
Lines 3-10 Link Here
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License 2.0
4
 * are made available under the terms of the Eclipse Public License 2.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/legal/epl-2.0/
6
 * https://www.eclipse.org/legal/epl-2.0/
7
 *
7
 *
8
 * SPDX-License-Identifier: EPL-2.0
8
 * SPDX-License-Identifier: EPL-2.0
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
Lines 49-65 public class SimpleBufferedRandomAccessInputStream extends InputStream Link Here
49
49
50
    public final byte[] readDirect(long position, int length) throws IOException
50
    public final byte[] readDirect(long position, int length) throws IOException
51
    {
51
    {
52
        byte[] buff = new byte[length];
53
        ByteBuffer bb = ByteBuffer.wrap(buff);
52
        int totalRead = 0;
54
        int totalRead = 0;
53
        while (totalRead < length)
55
        while (totalRead < length)
54
        {
56
        {
55
            int read += raf.getChannel().read(buffer, position);
57
            int read = raf.getChannel().read(bb, position);
56
            if (read < 0)
58
            if (read < 0)
57
            {
59
            {
58
                throw new IOException("incomplete read while performing read on buffer");
60
                throw new IOException("incomplete read while performing read on buffer");
59
            }
61
            }
60
            totalRead += read;
62
            totalRead += read;
63
            position += read;
61
        }
64
        }
62
        return buffer.array();
65
        return buff;
63
    }
66
    }
64
67
65
    public final int read() throws IOException
68
    public final int read() throws IOException

Return to bug 570670