Java InstantCode. Developing Applications Using Java NIO
To test the File Search application:
-
Set the path of the bin directory of J2SDK by executing the following command at the command prompt:
set path=%path%;D:\j2sdk1.4.0_02\bin;
-
Set the classpath of the lib directory of J2SDK by executing the following command at the command prompt:
set classpath = %classpath%;d:\j2sdk1.4.0_02\lib;
-
Copy the Search.java, FileList.java, and Help.java files to a folder on your computer. Next, compile the files using the javac command as follows :
javac *.java
-
To run the File Search application, specify the following command at the command prompt:
java Search
-
Click the Browse button on the File Search Utility window to specify the location where you want to search for files.
-
Specify a text string in the Containing text box to limit your search to those files that contain this text pattern.
-
Click the Search button to start the file search process. The File Search Utility window with the search results appears, as shown in Figure 4-4:
Figure 4-4: The File Search Utility Window with File Search Results
The right pane of the window shows the name and size of 974 files that are located within the C:\Test folder and contain the text string, java. The window also displays the start positions of the text pattern, java, in these 974 files.
Категории