i'm want to code a method that reads part from files into byte-arrays. for this i'm using fileinputstream and a buffered inputstream.
like this:
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
I do this only once by calling a method name "OpenFile(String File)". Once the File has been opened with this method, i try to operate with the function: "ReadParts(byte[] buffer, int offset, int len)"
dis.read(buffer, offset, len);
for(int i = 0; i < buffer.length; i++) System.out.print((char)buffer[i]);
// used data:
// file = "C:\Temp\test.txt" with a size of 949
// buffer: always in this case with a size of 237, except for the last one its 238
// offsets: 0, 237, 474, 711
// len is always 237, except for the last one its 238
the line dis.read() throws after the first step always a indexOutOfBounds errormessage but i can't figure it out why and what. using the netbeans debugger didnt helped, since i can't find the problem with the indices.....