To test the Encoder/Decoder 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 EncoderDecoder.java and EncodingSchemes.java files to a folder on your computer. On the command prompt, use the cd command to move to the folder where you have copied the Java files. Compile the files using the following javac command:
javac *.java
To run the Encoder/Decoder application, specify the following command at the command prompt:
java EncoderDecoder
The above code opens the main window of the Encoder/Decoder application, as shown in Figure 8-2.
Click the Browse button and select the test.txt file from the C drive of the computer.
Figure 8-4 shows the contents of the test.txt file:
Figure 8-4: Displaying test.txt File in the Encoder/Decoder Application
Click the Select Encoding Scheme button to open the Encoding Schemes dialog box and select the UTF-16BE encoding scheme.
Click the OK button of the Encoding Schemes dialog box.
Click the Encode button to encode the test.txt file using the UTF-16BE encoding scheme, as shown in Figure 8-5:
Figure 8-5: Displaying Encoded File in the Encoder/Decoder Application
Click the Decode button to decode the encoded file, as shown in Figure 8-6:
Figure 8-6: Displaying Decoded File in the Encoder/Decoder Application
Click the Reset button to reset the Encoder/Decoder application.
Specify the text you want to encode in the Text to Encode text area, as shown in Figure 8-7:
Figure 8-7: Displaying Text to Encode in the Encoder/Decoder Application
Repeat steps 6 through 9 to encode and decode the text specified in the Text to Encode text area. The results are displayed in Figure 8-8:
Figure 8-8: Displaying Encoded and Decoded Text