The data file in Exercise P19.6 may end up with many deleted records that take up space. Write a program that compacts such a file, moving all active records to the beginning and shortening the file length. Hint: Use the setLength method of the RandomAccessFile class to truncate the file length. Look up the method's behavior in the API documentation.

Complete the following file: