Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
Applet.java, for example, you'll see a frame that looks like the following snapshot:
Here, the text lines are just lined up using a black square as line separator symbol. When the chain of lines is getting too long, the output is continued in a new line of the frame.
This Java Tip will help you understand and overcome problems with the representation of the line separator on different systems. It introduces
a conversion program called EOLConverter (EOL is an abbreviation for "end of line,") which enables you to get a frame that looks like this:

Now the black squares have vanished into thin air and each line of text is printed on its own line. To see this, just compare the colored regions in this frame to the corresponding regions in the last frame.
The conversion of the line separator chosen on the system of the text's author to the line separator used on your system is achieved by the application EOLConverter.java.
Copy this file to the directory housing files you want to convert. Compile the source code by executing the command
javac EOLConverter.java
and start the application by invoking the Java interpreter through the command
java EOLConverter
Please note that the application only converts files with the extensions .htm, .html, .java, and .txt, and that the files in the subdirectories of all levels in your current directory are converted, too.
In the section Analyzing classes, you'll learn how the classes BufferedWriter and BufferedReader in the paackage java.io.* manage the line separator.
In the section Understanding EOLConverter, you'll find a detailed discussion of the statements and the execution flow performed in this application.
Now we proceed with the discussion of two essential classes we'll use in our application. The source code for these classes is shipped with the JDK 1.2, and is installed automatically if you don't deactivate the corresponding checkbox during the installation process.
Move to the directory jdk1.2 and unjar the file src.jar by executing the command:
jar -xvf src.jar
You should now find the source files of the API 1.2 in the directory jdk1.2/src.
Edit the file BufferedWriter.java, which is stored in the directory jdk1.2/src/java/io.
private String lineSeparator;
lineSeparator is initialized bylineSeparator = (String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("line.separator"));
Hence the line separator string is defined by the system property line.separator which depends on your system. For example, the value of the line separator is \n on Unix systems and \r\n on Windows systems.
java.io.*, see the following section of the Java Tutorial http://java.sun.com/docs/books/tutorial/essential/io/index.html
BufferedReader class at http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedReader.html
BufferedWriter class at http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedWriter.html
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq