I have this code..
String you = buf.readLine(); Log.d("STRING", ikaw); StringTokenizer st = new StringTokenizer(you); double lat = Double.parseDouble(st.nextToken()); double lng = Double.parseDouble(st.nextToken()); int type = Integer.parseInt(st.nextToken()); String text = st.nextToken(); Log.d("File Reading stuff", "success = " + lat); Log.d("File Reading stuff", "success = " + lng); Log.d("File Reading stuff", "success = " + type); Log.d("File Reading stuff", "success = " + text);
How am i suppose to test if it is already the end of file?
I don’t know how many lines there are in my file and I need to print all of them.
I know i should place my code inside a while loop, but I have no idea how to get the end of file.
I assume the code you have listed is inside a loop, and I assume buf is an instance of BufferedReader. You just need to check for null after you call readLine(). It returns null when you’ve hit the end of the file.