Java Reference
In-Depth Information
3-5. Write a program that lists all of the files and subdirectories in a specified
directory, along with their sizes and modification dates. By default, the output
should be sorted by name. If invoked with the -s option, however, output
should be sorted by size from largest to smallest. If invoked with the -d
option, output should be sorted by date, from most recent to least. Use the
sort() method of java.util.Collections to help with the sorting.
3-6. Write a program named Uncompress that uncompresses files and directories
compressed by the Compress example in this chapter.
3-7. Write a subclass of OutputStream named TeeOutputStream that acts like a T
joint in a pipe; the stream sends its output to two different output streams,
specified when the TeeOutputStream is created. Write a simple test program
that uses two TeeOutputStream objects to send text read from System.in to
System.out and to two different test files.
3-8. Write a simple subclass of Reader named TestReader that returns the same
character (a character passed to the constructor) over and over. The stream
should never reach EOF. Write a trivial subclass of Writer named NullWriter
that simply discards any output sent to it. Streams like these are occasionally
useful for testing and other purposes. Write a test program that reads from the
TestReader and sends its output to a PrintWriter wrapped around a Null-
Writer .
Search WWH ::




Custom Search