well.. i was thinking about a solution which allow me to use a byte[] buffer bigger than 8192.. so i write a static method like this:
Code:
public static int getMaxSizeExpByteArray(){
byte [] b;
int i = 15;
boolean exit = false;
while(!exit){
try{
b = new byte[(int)Math.pow(2,i)];
i++;
}
catch( java.lang.OutOfMemoryError ex) {i=i-2; exit=true;}
}
return i;
}
Ok.. i know that a method like this one is the DarkSide of java programming :).. but with this i can read more data .. iteration by iteration .. because my byte[] array is very bigger than 8192.. and at the same time i'm sure to never receive an heap out of memory error....
any comments?