Wuu Yang, <wuuyang@cis.nctu.edu.tw>, EC332B, 03-5712121 ext. 56614.
This lecture meets every Tuesday night 6:30-9:30 pm, from July 12 2005, for 9 times. This course will last for 9 weeks.
2nd lab: traffic.pdf
Answer to 3rd lab: CopyDirFile.java.
Try work022
http://www.cis.nctu.edu.tw/~wuuyang/Lecture/lecture.java.html
With the rapid deployment of the internet, the World-Wide-Web quickly becomes one of the most useful tools in our daily work and entertainment. The Java language is closely combined with the Web. Java has become a very practical programming language due to its true cross-platform nature, which is well worth your investment to learn. In this course, we will discuss applications of WWW and Java programming for the Web. We plan to cover the following material:
The textbook for the class is: Mary Campione and Kathy Walrath, The Java Tutorial, Addison-Wesley, 1996. List price NT$980, 831 pages. An on-line copy of the book is here. This textbook is on Java version 1.0. The current version of Java is 1.4. If you want to buy books about Java, buy the newer books.
(reference only)D. Flanagan, Java in a Nutshell, 3rd ed., 1999. This is a good reference on the new version (versions 1.2 and 1.3) of Java.
(reference only)G. McGraw and E.W. Felten, Java Security, Wiley, 1997. This book discusses security issues in Java and in networking.
1. log in one of cissol1, cissol2, cissol3, or cissol4.
2. Add /usr/local/java/jdk
3. Java compiler is javac. Java interpreter is java.
4. To see the manual page, use "man javac" and "man java".
It is said Java provides hiding, overriding, and overloading. Please explain the three terms: hiding, overriding, and overloading.
In this project, you need to install JDK 1.3 (downloaded from this page) on your personal computers. After that, you need to edit, compile, and run the first two examples on the classnotes, one for an application, and the other for an applet.
Write a program to sort the following integers. Hint: use arrays and basic Java statements. 11 23 9 48 6 15 63 2
Sort the above numbers with quicksort.
Implement the Eratoshenes Sieve for prime numbers.
Copy a file.
Copy all the files and subdirectories in a directory.
Backup is a practical, but difficult piece of work. When we work on the computers, our files are saved on the hard disks. Though hard disks are quite reliable nowadays, to avoid the serious trouble of losing data, it is absolutely necessary to save copies of the files on a separate medium. The separate medium used to be a tape drive. It could also be another hard disk.
In our project, we consider backup with anther hard disk. Our strategy is to make an identical copy of the working hard disk on the backup hard disk at the midnight of every day. This method is called \f5periodical disk mirroring\f6.
A straightforward way of backup is to copy all the files on the working hard disk to a second disk every day. When the size of the working files is too voluminous, complete backup may take too much time. We note that, though the size of all the working files could be voluminous, only a small fraction of all the working files are modified each day. It saves a lot of time if only modified files are copied to the backup hard disk.
The situation at the midnight of every day is as follows: we have a backup disk, containing all the files at the beginning of the day and a working disk, containing all the files at the end of the day. We want to copy necessary files from the working disk to the backup disk so that the backup disk will become identical to the working disk.
To determine whether an old file and a new file differ, we simply check the modification times of the files. If the modification times are different, we assume that the file is modified and needs to be copied to the backup disk.
In this project, you need to implement a backup utility in Java to mirror disks. Specifically, you need to implement the following features:
You probably need to consult the java.io.File class for this project.
You are asked to write an FTP server similar to Servu and an FTP client similar to cutFtp. Each must come with a friendly user interface.
You probably need to consult the java.io.File class for this project.
Rewrite the client/server example in chapter 11 so that the server creates a new thread when a client tries to connect to the server. The original server then is free to accept new connection requests from other clients. Your server should be able to serve at most five clients simultaneously. When a sixth client attempts to connect to the server, the server should tell the sixth client to try the connection a few minutes later. The original source code is available here.
This question is concerned with the creation of a very simple file manager that comes with a graphical user interface. Suppose that we have a hierarchical file system, similar to the one in the Unix system. A file is addressed as /export/home/funnyguy/personal/letter.doc. You need to create a window that contain a menu bar and four panels as follows:
-------------------------------------------------------------- | file | | -------------------------------------------------------------- | directory name /export/home/funnyguy | -------------------------------------------------------------- | | | panel 2 | | | -------------------------------------------------------------- | directory name /export/home/funnyguy/letter | -------------------------------------------------------------- | | | panel 4 | | | --------------------------------------------------------------
In the menu bar, there is a single file menu.
It contains a single action exit. When the exit button
is clicked, the file manager should close its window and stops.
In panel 2 and panel 4 above, there is one icon for each file or subdirectory in the current directory. There is a also an icon that represents the parent directory. Place the parent directory at the upper-left corner of the panel.
A user may do three things in this file manager window:
First, she/he may travel to the parent directory or a subdirectory by
double-clicking appropriate icons. Second, she/he may type the name of a
directory in the first or third panel. When the enter key is hit, the
system will display the content of the directory in panel 2 (or panel 4). If
what the user types is not a directory name, the file manager should display a
warning message. You should implement this action with Java exceptions.
The third thing a user can do is to drag an icon (representing a file, not a directory) from panel 2 to panel 4 (or from panel 4 to panel 2). The file manager will attempt to copy the file to the destination directory. If there is already a file with the same name in the destination directory, the file manager should ask the user whether she/he wants to overwrite the existing file. You may implement this part with the dialog component.
To make the question easier, we will assume that
You probably need to consult the java.io.File class for this project.
Give a sequence of line segments, you need to draw these line segments on a canvas. The input file has the form:
[pair (coord (0.0,0.0),coord (0.0,3.0)),pair (coord (0.0,3.0),coord ( ~2.598076144366072,4.500000116025305)),pair (coord (~2.598076144366072, 4.500000116025305),coord (0.0,6.0)),pair (coord (0.0,6.0),coord (0.0,9.0))]
Here [ ... ] denotes a sequence of line segments. Each segment is denoted by pair( ... ). The notation coord(0.0, 3.0) represents the coordinates of a point in a plane.
java.lang, java.io and java.util of its Application Programming Interface. The intention is
that the behavior of every language construct is specified here, so that
all implementations of Java will accept the same programs.