Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PrinterWriter method

 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The famous java.io.PrintWriter which we use in servlets..,
What is the difference between
out.print("something");
out.write("something");
thanks,
yogen
 
Andres Bonifacio
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Essentially the same. Calls to write is inside print. See code below.
public void print(String s) {
if (s == null) {
s = "null";
}
write(s);
}
[ May 28, 2003: Message edited by: Andres Bonifacio ]
 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andres,
You mean to say that print() calls the write().
How did you find this!!
Can you please point me to the documentation.
cheers
yogen
 
Andres Bonifacio
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find the source code on <JDK_HOME>/src.zip
 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Andres,
I figured it out myself. That was a clever one!!
Guess you decompiled the java.io.PrintWriter class from rt.jar.
yogen
 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Mate,
I did not realize that you had already posted the reply.
I take back my previous mail.
Thanks for your help.
yogen
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!