21 - File IO
Alina
Goals
- Be able to read a file from the computer
- Be able to write to a file on the computer
- Know different file formats, be able to differentiate these formats
Slides
Useful links
File IO
- https://docs.oracle.com/javase/tutorial/essential/io/file.html
- https://docs.oracle.com/javase/7/docs/api/java/io/File.html
- https://www.w3schools.com/java/java_files.asp
- https://www.mkyong.com/java8/java-8-stream-read-a-file-line-by-line/
- https://www.baeldung.com/reading-file-in-java
Homework
Exercise 1
- Download and save a txt file http://norvig.com/big.txt
- Replace "Sherlock" name with your name
- Create and save the data to a new file with the name "Adventures of your name"
Exercise 2
- Create 2 different files
- Read both of them
- Create a new file that has data from two files
Exercise 3 (CSV)*
- Create a csv file with payments
id, amount, category, month, year
1, 10.0, Cafe, 10, 2019
2, 2100.0, Salary, 10, 2019
...
- find a library to work with csv files, parse the file
- add these data to your Bank Application
Exercise 4 (XML)*
- Create an xml file with payments
- find a library to work with xml files, parse the file
- add these payments to your Bank Application
Exercise 5 (json)*
- Create a json file with payments
- find a library to work with json files, parse the file
- add these payments to your Bank Application
Exercise 6 (json)*
- Create few payments
- Save these payments as json file