Week 9 (Object Serialization - saving Data Structures to file.)

  1. Check that you can create a mysql database on igor read this.
  2. Take a copy of mysql-connector-java-5.1.7-bin.jar nd add it to your CLASSPATH. This is what you need to connect to a mysql database server in Java.

  1. Watch video about Object Serialization 6

  2. Read http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectOutputStream.html.

  3. Adapt week5/WordSort.java so it saves the map to a file. Solution

  4. Read http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectInputStream.html.

  5. Adapt week6/solutions/WordSortMapToFile.java so it reads the map from the file and prints it out. Solution

  6. (Easy Assignment) Adapt week1/solutions/one.java so it saves the list in a file. Write another program like week6/solutions/readMapFromFile.java which reads the list from file and prints it out.

  7. (Hard Assignment) Adapt week4/solutions/sameSite2.java so it produces a

    TreeMap  <String, HashSet<String>> linksTo
    

    Which for every URL visited it gives us the set of links in the corresponding page. Save the TreeMap linksTo in a file.

    Write another program which prints the contents of the TreeMap stored in the file.

s.danicic@gold.ac.uk
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2015-09-04