String, text, numbers, I/O II part
"SEQ7";
How do I pull "7" from the string and convert it to an integer?
Answer: I d do something like this:
StringBuffer digits = new StringBuffer();
char c;
for (int i=0; i
c = strSEQ.charAt(i);
if (Character.isDigit(c))
digits.append(c);
}
int intValue = Integer.parseInt(digits.toString());
Michiel
Q: How can I display other languages such as chinese, french, japanses etc.
inside applet or frame?
Answer: You have to install the approriate font, and add it to a font.properties file.
Further information can be found here:
http://java.sun.com/products/jdk/1.1/docs/guide/intl/index.html
http://developer.java.sun.com/developer/qow/archive/65/index.html
http://forum.java.sun.com/read/16805306/q_CUP8NP 1rgAAYsA#LR
Linda
Q: I have a string like 23,N/A,,N/A,87, then I used the StringTokenizer t = new
StringTokenizer( s, ",");
to get the token. I seems I only got 4 tokens back, not 5. How doesStringTokenizer
treat the ,, in this case? I had tried String.equals("") or String.equals(null) to pick the
EMPTY string between ,, , it did not work.
Anyone can give a clue?
Answer: You can tell it to return the delimiters as well as the tokens. When you
receive two consecutive delimiters you know that the token was empty.
/gordon
or
There is another constructor, with a third parameter. Using that one, you can get
the boundary markers, such as the comma, returned to you as well. That would allow
you to handle your empty strings.
Michele.
Q: How to know in Java if a given font has or not a fixed width ?
For example to list all the "fixed width" fonts that are available on the user s platform.
Answer: I m not sure whether there s an easier solution... if there is none, you might
try to get the FontMetrics objects from a specific Font. Then iterate over every
file:///F|/a_jsite/350_tips/stings_text__date_numbers_io II.htm (2 of 7) [2001 07 08 11:25:00]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved