COP3337 Programming II Assignment 3



Write a Java program to imitate a certain file system and certain utility programs of an operating system. Design a class called BasicFile to carry out certain file operations: First, select a file from a file dialog box, using the class JFileChooser. Part IFile securityAfter the file has is opened make a backup copy of it before anything else is done. . Use the class JFileChooser again to select/specify the backup filename. Use the DataInputStream and DataOutputStream classes, and the readByte and writeByte methods respectively for this activity.Part IIFile OperationsList the absolute path of the fileList all files, directories and subdirectories that are in the path of the file selected.State the size of the selected file.File Contents- account for the following information:The number of lines in the fileThe number of words in the file, and The number of characters in the file excluding blanks. Numbers must be treated as strings. Use the class StreamTokenizer for this. For instance when this option is chosen the program should output a line saying something like this:File: xxx.txt has 120 lines, 317 words, 4154 characters (approximately)Searching the fileSearch the file line by line for a given string. The output must contain the line number followed by the contents of the line that contains the search argument. For instance given the following as input string: Java, where Java is the search string the output would be something like this:5: on the island of Java9: The people of JAVA loves jaVa.Use the class LineNumberReader for this exercise.OutputThe output for Part I must be in a different file form Part II.Test classWrite a class called TestBasicFile to test your class. (You may use the one we started in class) NOTE: Use recursion for the following two itemsList all files, directories and subdirectories in the path of the file selected.Search the file line by line for a given string. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download