Tutorial 10
Tutorial 10
Tutorial 10
Exercise 1 (required)
Build a utility library XFile with read() and write() functions allowing reading and writing
binary files. Utilize the above library to copy one file to another.
GUIDELINES:
Create the XFileDemo class containing the main() method and utilize the XFile library
as follows:
Exercise 2 (required)
Extend the XFile library with two functions allowing reading and writing objects from/to a
file.
Write code for the readObject() function
Exercise 3 (required)
Realize a Java class Matrix to represent bidimensional matrices of real numbers. The class
should export the following methods:
Matrix(int n, int m) : constructor that creates a matrix of size n × m, with all values
initially set to 0;
void save(String filename) : that saves the content of the matrix on the file
specified by filename;
static Matrix read(String filename) : that reads the data about a matrix from
the file specified by filename, creates the matrix, and returns it;
Matrix sum(Matrix m) : that returns the matrix that is the sum of the object and of m,
if the two matrices have the same dimensions, and null otherwise;
Matrix product(Matrix m) : that returns the matrix that is the product of the object
and of m, if the two matrices have compatible dimensions, and null otherwise.
Exercise 4 (required)
Realize a class IOFile that exports some functionalities on text files. The class should have a
constructor with one parameter of type String, representing the name of the file on which to
operate, and should export the following methods: