Я поместил файл "ecg.text" в каталог mnt / sdcard / ecg / ecg.text и затем использую следующий код для его чтения, но продолжаю получать улов (FileNotFoundException).Любая помощь или предложения о том, как найти файл, будет принята с благодарностью.
Заранее спасибо.
Основной класс активности:
ECGFilereader reader;
try {
reader = new ECGFilereader("ecg");
reader.ReadFile(waves);
for (int chan=0; chan<ECGFilereader.numChannels; chan++) {
waves[chan].drawSignal(c, (wavePos[chan])); //new Waveform may need to be created
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
и ECGFilereader.java
public class ECGFilereader {
public final static int numChannels = 12; // the data is stored in 12 channels, one for each lead
public final static int numSamples = 500*6; //500 = fs so *6 for 6 seconds of data
public File file;
private Scanner scanner;
short [] [] ecg = new short [numChannels] [numSamples];
public ECGFilereader (String fname) throws FileNotFoundException
{
File dir = Environment.getExternalStorageDirectory(); //accesses the ecg file from the SD card
file = new File(dir, "mnt/sdcard/ecg/ecg.text");
scanner = new Scanner(file);
}
public boolean ReadFile(Waveform[] waves) // sorts data into and array of an array (12 channels each containing 5000 samples)
{
for (int m=0; m<numSamples && scanner.hasNextInt(); m++)
{
int x = scanner.nextInt();
for (int chan = 0; chan<numChannels && scanner.hasNextInt(); chan++)
{
ecg [chan] [m] = (short) scanner.nextInt();
}
}
for (int chan=0; chan<numChannels; chan++)
waves[chan].setSignal(ecg[chan]); // sets a signl equal to the ecg array of channels
return true;
}
}