Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4 Read all the lines in the file
- .
- You need to use your scanner again in this section to read every line in the file. At this stage
- we will just read each line and then print it. The Scanner functions you need to do this are:
- • in.hasNext(): will return true when there are more lines of data to read. It will
- eventually return false when you get to the end of the file
- • in.nextLine(): this function will return the next line of text from the file. You need to
- declare another local variable and use an assignment statement as you did when you
- read the header line in step 3 above.
- 1. Write a while statement at the end of your setup, in which the boolean expression
- uses the hasNext function to determine whether there are more lines of data to read.
- 2. Inside the while statement, write a line to read the next line of data and save it into a
- local String variable called csv. This variable will hold a line of csv data.
- 3. Also inside your while statement, add a println statement to print the value of csv.
- Run your program. You should see each line of data printed in the console panel. If there
- 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