All Packages Class Hierarchy This Package Previous Next Index
Class tw.edu.ncnu.im.cnclab.Tools.StringTool
java.lang.Object
|
+----tw.edu.ncnu.im.cnclab.Tools.StringTool
- public class StringTool
- extends Object
The StringTool class provides some method of String processing.
- Version:
- 0.4 Jul 8, 1999
- Author:
- Ding-Yi Chen
-
doubleToString(double, int)
- Translate double to String.
-
doubleToString(double, int, int)
- Translate double to String.
-
getSimpleClassName(Class)
- Get the simple name of the class.
-
getSimpleClassName(String)
- Get the simple name of the class.
-
longToString(long, int)
- Translate long int to String.
longToString
public static String longToString(long l,
int len)
- Translate long int to String.
- Parameters:
- l - The long int to translate.
- len - Specifies the length of the String.
- Returns:
- The result String.
doubleToString
public static String doubleToString(double d,
int precision)
- Translate double to String.
- Parameters:
- d - The double to translate.
- precision - Specifies the number of digits to appear after the decimal point.
- Returns:
- The result String.
doubleToString
public static String doubleToString(double d,
int precision,
int len)
- Translate double to String.
Note:
If the length of translated string greater than len
, the tail of the String will be truncated and replaced by '~' .
If the length of string less than len
it will be blank-padded on the left of the String.
Examples
- doubleToString(12345.12345,2,5): "1234~"
- doubleToString(12345.12345,2,13: " 12345.12345"
- Parameters:
- d - The double to translate.
- precision - Specifies the number of digits to appear after the decimal point.
- len - Specifies the length of the String.
- Returns:
- The result String.
getSimpleClassName
public static String getSimpleClassName(Class theClass)
- Get the simple name of the class.
If the class is java.lang.Object
, then return the simple name "Object" .
- Parameters:
- theClass - The Class.
- Returns:
- the simple name.
getSimpleClassName
public static String getSimpleClassName(String str)
- Get the simple name of the class.
If the class is java.lang.Object
, then return the simple name "Object" .
- Parameters:
- str - The fully-qualified name.
- Returns:
- the simple name.
All Packages Class Hierarchy This Package Previous Next Index