27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

String, text, numbers, I/O I part<br />

boolean x = true;<br />

getBoolean(x);<br />

will show false!!!!<br />

Why <strong>Java</strong> has method that doesn't work? Is it bug in <strong>Java</strong> or I am stupid?<br />

Answer: neither statement is true! It is not a bug and you are Ok! Just please read<br />

more carefully <strong>Java</strong>Doc next time.<br />

It is written there for getBoolean ():<br />

"Returns is true if and only if the system property named by the argument exists and<br />

is equal to the string "true".<br />

(Beginning with <strong>Java</strong> 1.0.2, the test of this string is case insensitive.)<br />

A system property is accessible through getProperty, a method defined by the<br />

System class."<br />

So you didn't use this method properly...<br />

Use instead:<br />

public static Boolean valueOf(String s)<br />

This method returns the boolean value represented by the specified String. A new<br />

Boolean object is constructed. This Boolean contains the value true if the string<br />

argument is not null and is equal, ignoring case, to the string "true".<br />

example:<br />

boolean x= true;<br />

(Boolean.valueOf(x)).booleanValue()<br />

gives you proper boolean (not Boolean!) value<br />

Q: I'm working on a java project and looking for a better API that can generate<br />

PDF, work with Excel, Word documents... Where can I find it?<br />

Answer: We have a list here:<br />

http://www.javafaq.nu/java/office/index.shtml<br />

Q: I'm looking for a rich text editor that I can embed within a web page, and allow<br />

users to enter rich text that I can in turn store as HTML.<br />

I've seen similar applets through web based e-mail clients. I'd appreciate it if<br />

someone could point me in the right direction!<br />

Answer:<br />

Try Swing, by Robinson, Manning Publication. You could probably adjust the code to<br />

fit into the applet style.<br />

It is here<br />

http://javafaq.nu/java/free-swing-book/free-swing-book-chapter20.shtml<br />

John<br />

Q: I want to have a while loop execute for a maximum of n seconds or until it<br />

receives something in an input stream. How would I do this?<br />

Answer: I think you could do it this way:<br />

********************************************<br />

InputStream Input=null;<br />

file:///F|/350_t/350_tips/stings_text__date_numbers_io-I.htm (5 of 7) [2002-02-27 21:19:16]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!