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 />
Answer: Try this:<br />
String a = "This is a\nmultiline string"<br />
A "\n" stands for a line feed. Take a look at the <strong>Java</strong> language specification<br />
(downloadable on Sun's site), it has a section about strings.<br />
Answer2: You mean like this?<br />
String a = "" +<br />
" " +<br />
" this is html." +<br />
" " +<br />
"";<br />
I am doing some servlet programming and I need to include a few " in a string.<br />
How can I do this?<br />
Answer: By using the escape character \ like so:<br />
String s = "\"";<br />
I cannot find the method to convert a binary number to an int. I used<br />
Integer.toBinaryString to get a decimal to binary but I don't know how to to convert it<br />
back.<br />
Answer: Try using Integer.parseInt(String s, int radix) with radix = 2<br />
that should do your job.<br />
How do I launch a native Document by its Associated MIME Type? For example,<br />
I would like to ask the 'operating system' what application is associated with .DOC<br />
and then launch it.<br />
Answer: On WinNt,<br />
String docName = "c:\\someyourdir\\nameofdoc.doc";<br />
Runtime.getRuntime().exec("cmd.exe /c "+docName);<br />
Q: How do I indicate Unicode characters that cannot be represented in ASCII,<br />
such as ö?<br />
Answer: from "<strong>Java</strong> Tutorial<br />
(http://java.sun.com/docs/books/tutorial/i18n/text/convertintro.html)<br />
"To indicate Unicode characters that cannot be represented in ASCII, such as o, we<br />
used the \uXXXX escape sequence. Each X in the escape sequence is a<br />
hexadecimal digit. The following example shows how to indicate the o character with<br />
an escape sequence:<br />
String str = "\u00F6";<br />
char c = '\u00F6';<br />
Character letter = new Character ('\u00F6'); "<br />
When I tried to read one string representing boolean value and convert it into<br />
boolean it didn't work. Finally I found that <strong>Java</strong> API has a bug!<br />
I wrote the program that uses redaing ini file settings for initialization. All settings in a<br />
file are strings. I am converting them to appropriate type during reading. When I tried<br />
to read one string representing boolean value and convert it into boolean it didn't<br />
work. Finally I found that <strong>Java</strong> API has a bag:<br />
file:///F|/350_t/350_tips/stings_text__date_numbers_io-I.htm (4 of 7) [2002-02-27 21:19:16]