Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindbright.util
Class StringUtil

    java.lang.Object
      com.mindbright.util.StringUtil

public final class StringUtil
extends java.lang.Object

Static utility functions for trimming strings and converting byte counts to strings.

Constructor Summary
`StringUtil()`

Method Summary
`static java.lang.String` | `nBytesToString(long nBytes, int digits)` Converts a byte count to a readable string with an unit .
`static java.lang.String` | `trimLeft(java.lang.String str)` Trims space from the start of a string.
`static java.lang.String` | `trimRight(java.lang.String str)` Trims space from the end of a string.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### StringUtil

    public StringUtil()

Method Detail

### trimLeft

    public static java.lang.String trimLeft(java.lang.String str)

  Trims space from the start of a string.

  Parameters:
    `str` - string to trim space characters from
  Returns:
    a new string without any leading space characters

### trimRight

    public static java.lang.String trimRight(java.lang.String str)

  Trims space from the end of a string.

  Parameters:
    `str` - string to trim space characters from
  Returns:
    a new string without any trailing space characters

### nBytesToString

    public static java.lang.String nBytesToString(long nBytes,
                                                  int digits)

  Converts a byte count to a readable string with an unit . If the byte count contains too many digits the unit is upgraded to Kb, MB, GB or TB until the number fits withing the given number of digits. For example converting 1024 with digits=4 gives "1024 Bytes: but with digits=3 it becomes "1 kB".

  Parameters:
    `nBytes` - the byte count to print
    `digits` - how many digits the printout may contain. Note that this count does not include the unit length
  Returns:
    a formatted string

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD