jeudi 5 mars 2015

FileWriter EBADF error



I am reading whole lines from part of 1 csv file and writing the lines to another csv file. There are about 10,000 records to be written. After I written about 3000 records (doesn't fail on the same record every time), I get an EBADF error (bad file number) on the filewriter.write line. I have the manifest entry for write permissions, and this works on my Galaxy S4 but not on an old Nexus phone and not on a Note tablet. Both of the failing units have lots of free space. The section of code failing is:



while (saveSegmentCounter < 21000 && eofACC==false) {
//write the NewFile.acc record
try {
fACCWriter.write(lineACC+"\n"); //why does this fail after about 3000 records and then every 47 records
saveSegmentCounter++;
} catch (IOException e) {
Log.d(tag, "Simple Read Write - Catch when writing record number "+saveSegmentCounter); //Fails every 54 or 53 records???
//Log.d(tag, "Simple Read Write e.getmessage: "+ e.getMessage()); //Fails every 54 or 53 records???
e.printStackTrace();
}
ReadACCFile(null); //read the next S4.acc record


}




Aucun commentaire:

Enregistrer un commentaire