You can read the file backwards, until you find a number that is a normal Double num:
BufferedReader reader = new BufferedReader(new FileReader(
"cashTest"));
String s;
StringBuilder tmp = new StringBuilder();
while ((s = reader.readLine()) != null) {
tmp.append(s.toLowerCase() + "\n");
}
double num = 0.0;
String[] arr = tmp.toString().split("\n");
// read the array backwards, starting with the last line
for (int i = arr.length - 1; i >= 0; i--) {
try {
num = Double.valueOf(arr[i]);
// if the number cannot be converted to a Double, it would mean that it is one of the other lines
// if it can be converted, then break out of the for loop
break;
} catch (NumberFormatException e) {
// just for a test mess
System.out.println("Not on this line");
}
}
// just to make sure that the value we got was greater than 0
if (num > 0)
System.out.println(num);
else
System.out.println("No customer records found. A possible error occured");