I have to read data from two files. For that, I have to iterate these two files using while. Here is my code...
// Data in File1 are A, B, C, D // Data in File2 are A, B,C
Scanner scanFile = new Scanner(new DataInputStream(fOne));
while (scanFile.hasNextLine())
{
countTwo = 0;
if(scanFile.nextLine()!=null)
{
count++;
Toast.makeText(getBaseContext(), "Count : " + count, 500).show();
}
else
scanFile.close();
Scanner scanFileT = new Scanner(new DataInputStream(fTwo));
while(scanFileT.hasNextLine())
{
if(scanFileT.nextLine()!=null)
{
countTwo++;
Toast.makeText(getBaseContext(), "CountTwo : " + countTwo, 500).show();
}
else
scanFileT.close();
}
}
I am using while loop. What I am getting here, first time count = 1 and countTwo variable as 1, 2 and 3 and then again count variable as 2, 3, 4 (As data in file1 are 4 and in file2 are 3). Now I have to iterate outer while loop such as I get count values as count=2 and countTwo= 1, 2, 3. Again count=3 and countTwo = 1, 2, 3. Again count=4 and countTwo = 1, 2, 3. What needs to be done?