The Artima Developer Community
Sponsored Link

Java Answers Forum
Use of PrintWriter?

1 reply on 1 page. Most recent reply: May 29, 2002 12:20 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Java

Posts: 3
Nickname: artima
Registered: May, 2002

Use of PrintWriter? Posted: May 28, 2002 9:27 PM
Reply to this message Reply
Advertisement
Hi All,
When System.out.println can serve the purpose of printing the outputs to the console, then what is the need of using PrintWriter for the same.I have read that it is used for internationalization.What does this internationalization mean?Any pointers will be helpful.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Use of PrintWriter? Posted: May 29, 2002 12:20 PM
Reply to this message Reply
Sorry, there are no pointers in Java.

...has the uproarious laughter subsided? Hmm, I guess I won't quit my day job, just yet.

Internationalization means writing code that can be easily ported to other languages simply by changing the resources. That means not hard-coding strings for menu items, buttons, and so on, but instead, reading them from resources at runtime. The set of resources chosen at runtime is based on the current locale settings of the machine (that is, the region and language settings).

Many languages have double-byte character sets, so they cannot be represented by single-byte characters (that is, an array of byte). You should really be comparing PrintWriter and PrintStream, since System.out is an instance of PrintStream. The problem with PrintStream is that it converts the characters to single-byte characters, so it is not good for double-byte character sets and conseqently, not good for internationalization.

For simply printing to the console, System.out.println() is probably sufficient for your needs. After all, you probably aren't going to be trying to print Cuneiform to the console. You would want to use PrintWriter to write files if you wrote a text editor that you wanted to sell in a country that has a double-byte character set (or if you are the kind of person who plans ahead). However, in that case, you would not be using console output (except perhaps for debugging and the all-to-ubiquitous stack trace dumps), instead you would display the characters in a GUI, using the appropriate unicode font.

Flat View: This topic has 1 reply on 1 page
Topic: i need java-help! Previous Topic   Next Topic Topic: Virtual Memory is leaking in java.exe

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use