Ti rispondo volentieri perchè non si finisce mai di apprendere..
Ti confesso che sono mooooooooooooooooooooooooolto convinto di quello che ho detto però per la frase detta prima posto volentieri il codice...
LETTURA FILE
codice:
private String fastStreamCopy(File file)
{
String result=null;
FileChannel fileChannel = null;
try
{
fileChannel = new FileInputStream(file).getChannel();
MappedByteBuffer byteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());
int size = byteBuffer.capacity();
if (size > 0)
{
// Retrieve all bytes in the buffer
byteBuffer.clear();
byte[] bytes = new byte[size];
byteBuffer.get(bytes, 0, bytes.length);
result = new String(bytes);
}
fileChannel.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
if (fileChannel != null)
{
try
{
fileChannel.close();
}
catch (IOException ignore)
{
// ignore
}
}
}
return result;
}
SPLIT RIGA PER RIGA
codice:
do
{
int endIndex=result.indexOf('\n', fromIndex);
if(fromIndex>=size)
{
exit=true;
break;
}
String text = result.substring(fromIndex, (endIndex==-1 ? size : endIndex));
if(text.charAt(text.length()-1)=='\r')
text=text.substring(0, text.length()-1);
Object item = this.fileFilter.filter(row, text);
if (item != null)
{
//aggiungo l'elemento
this.listRows.add(item);
}
if(endIndex==-1)
exit=true;
else
{
++row;
fromIndex=endIndex+1;
}
}
while(!exit);
Quella che ho evidenziato in grassetto è la parte che poi richiama la parseDouble.
Se commento quella riga il tempo di esecuzione è zero! Se la lascio e viene richiamata la parseDouble il tempo è di oltre 1 secondo per circa 100.000 stringhe che rappresentano numeri (questo con la parseDouble) standard..
Ciao, ale500.