Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. 4 Read all the lines in the file
  2. .
  3. You need to use your scanner again in this section to read every line in the file. At this stage
  4. we will just read each line and then print it. The Scanner functions you need to do this are:
  5. • in.hasNext(): will return true when there are more lines of data to read. It will
  6. eventually return false when you get to the end of the file
  7. • in.nextLine(): this function will return the next line of text from the file. You need to
  8. declare another local variable and use an assignment statement as you did when you
  9. read the header line in step 3 above.
  10. 1. Write a while statement at the end of your setup, in which the boolean expression
  11. uses the hasNext function to determine whether there are more lines of data to read.
  12. 2. Inside the while statement, write a line to read the next line of data and save it into a
  13. local String variable called csv. This variable will hold a line of csv data.
  14. 3. Also inside your while statement, add a println statement to print the value of csv.
  15. Run your program. You should see each line of data printed in the console panel. If there
  16. are errors, go back and fix them. If there are no errors, delete the println statement.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement