fix for some improper details in kelondroDyn

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2104 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 20958acfd8
commit bb931c7b83

@ -44,6 +44,7 @@
package de.anomic.kelondro; package de.anomic.kelondro;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
@ -80,7 +81,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
len -= r; len -= r;
} }
} }
/*
public byte[] readFully() throws IOException { public byte[] readFully() throws IOException {
ByteArrayOutputStream dest = new ByteArrayOutputStream(); ByteArrayOutputStream dest = new ByteArrayOutputStream();
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
@ -94,7 +95,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
dest.close(); dest.close();
return dest.toByteArray(); return dest.toByteArray();
} }
*/
public byte readByte() throws IOException { public byte readByte() throws IOException {
final int ch = this.read(); final int ch = this.read();
if (ch < 0) throw new IOException(); if (ch < 0) throw new IOException();

@ -349,11 +349,13 @@ public class kelondroDyn extends kelondroTree {
} }
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
byte[] buf = getDyn(filekey, seekpos, len); int l = Math.min(b.length - off, len);
if (buf == null) return 0; byte[] buf = getDyn(filekey, seekpos, l);
System.arraycopy(buf, 0, b, off, len); if (buf == null) return -1;
seekpos += len; l = Math.min(buf.length, l);
return len; System.arraycopy(buf, 0, b, off, l);
seekpos += l;
return l;
} }
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {

Loading…
Cancel
Save