Mais rapidez na leitura de arquivo binário

[code]InputStream arqBin = new FileInputStream(fileName);

DataInputStream lerByte = new DataInputStream(arqBin);

String[] ss = null;

          while(( _flt = lerByte.readInt()) != -1){
	    	
	    	if(h == 0) {
                        lerByte.readByte();
                        ss[] = new String[81];
                        ss[0] = "True";
                    }
                    h++;

                    _flt = ( (_flt >>> 24 & 0x000000FF)   
		               | (_flt >>>  8 & 0x0000FF00)   
		               | (_flt <<   8 & 0x00FF0000)   
		               | (_flt <<  24 & 0xFF000000));  
	    	float flt = Float.intBitsToFloat(_flt);


                    ss[h] = ""+flt;

                   if(h == 80){
	    		model.addRow(ss);
                            h=0;
                    }
                      

                    
          }[/code]

Desta forma a leitura do meu arquivo binário está muito lenta.
Tem alguma outra forma de ler mais rápido?

Use um BufferedInputStream:

[code]DataInputStream lerByte = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName)));

String[] ss = null;
while(( _flt = lerByte.readInt()) != -1){
if(h == 0) {
lerByte.readByte();
ss[] = new String[81];
ss[0] = "True";
}
h++;
_flt = ( (_flt >>> 24 & 0x000000FF)
| (_flt >>> 8 & 0x0000FF00)
| (_flt << 8 & 0x00FF0000)
| (_flt << 24 & 0xFF000000));
float flt = Float.intBitsToFloat(_flt);
ss[h] = ""+flt;

if(h == 80){
    model.addRow(ss);
    h=0;
}
lerByte.close();

}[/code]

Veja também:
http://java.sun.com/developer/technicalArticles/Programming/PerfTuning/

Bom, eu não entendi o que o seu código faz exatamente, mas eu acho que você ganha um desempenho considerável se você fizer a leitura através de BufferedInputStream e fazer a leitura em arrays de bytes ao invés de ler int a int.

DataInputStream lerByte = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName)));

Só isso aqui já deu! Ficou muito muito mais rápido!

Valeu :slight_smile: