|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjsh.shell.Utils
public class Utils
The Java Shell: Utility pack.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static boolean |
beginsWithRoot(java.lang.String path)
It can be necessary to determine if a path begins with a root. |
static java.lang.String |
constructPath(java.lang.String change)
Constructs a new path from current user path. |
static java.lang.String |
fmtBytes(long bytes)
Formats a number of bytes for output. |
static java.lang.String |
fmtTime(long ms)
Formats time for output. |
static java.lang.String |
getRoot(java.lang.String path)
It can be necessary to determine which is the root of a path. |
static java.lang.String |
getShortStringOf(java.lang.String longString,
int maxLength)
Sometimes, Strings are too long to be correctly displayed. |
static int |
getSize(java.util.Enumeration enu)
Counts things in an Enumeration (and destroys it as a side effect). |
static java.lang.String |
getSpaces(int len)
Return a String made of spaces. |
static java.lang.String |
getUserDirectory()
Returns the user current directory. |
static java.lang.String[] |
getWildCardMatches(java.lang.String s,
boolean sort)
When the user has to specify file names, he can use wildcards (*, ?). |
boolean |
isHidden(java.io.File file)
We override a Java2 spcific method. |
static java.io.File[] |
listFiles(java.lang.String[] names,
boolean construct)
Because a lot of people still use JDK 1.1, we need this method to create an array of Files from an array of String. |
static java.io.File[] |
listRoots(java.io.File f)
We override a Java2 specific method. |
static boolean |
match(java.lang.String pattern,
java.lang.String string)
This method can determine if a String matches a pattern of wildcards |
static void |
sortStrings(java.lang.String[] strings)
Quick sort an array of Strings. |
static void |
sortStrings(java.lang.String[] a,
int lo0,
int hi0)
Quick sort an array of Strings. |
static java.lang.String[] |
subarray(java.lang.String[] arr,
int first)
Removes some leading elements from a String array. |
static java.lang.String[] |
subarray(java.lang.String[] arr,
int first,
int last)
Removes some elements from a String array. |
static void |
swap(java.lang.String[] a,
int i,
int j)
Swaps two Strings. |
static java.lang.String[] |
toArray(java.util.Vector strings)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static java.lang.String[] subarray(java.lang.String[] arr, int first, int last)
arr
- The array.first
- First element to keep (new 0-index).last
- Last element to keep.
public static java.lang.String[] subarray(java.lang.String[] arr, int first)
arr
- The array.first
- First element to keep (new 0-index).
public static java.lang.String fmtBytes(long bytes)
bytes
- Number of bytes.
public static java.lang.String fmtTime(long ms)
bytes
- Number of milliseconds.
public static java.lang.String getSpaces(int len)
len
- Number of spacespublic static java.lang.String[] toArray(java.util.Vector strings)
public static java.lang.String[] getWildCardMatches(java.lang.String s, boolean sort)
s
- Wilcardssort
- Set to true will sort file names
s
in current directory.match(String, String)
public static boolean match(java.lang.String pattern, java.lang.String string)
pattern
- The pattern used for comparisonstring
- The String to be checked
string
matches pattern
Utils#getWildCardMatches(String)
public static void sortStrings(java.lang.String[] strings)
string
- Strings to be sortedpublic static void sortStrings(java.lang.String[] a, int lo0, int hi0)
a
- Strings to be sortedlo0
- Lower boundhi0
- Higher boundpublic static void swap(java.lang.String[] a, int i, int j)
a
- The array to be swappedi
- First String indexj
- Second String indexpublic static java.lang.String getUserDirectory()
public static java.lang.String getShortStringOf(java.lang.String longString, int maxLength)
longString
- The String to be modifiedmaxLength
- The maximum length of the String
public static java.io.File[] listFiles(java.lang.String[] names, boolean construct)
names
- Names of the filesconstruct
- Set it to true if names does not contain full paths
public static int getSize(java.util.Enumeration enu)
enum
- The enumeration, in the start position.
public static java.lang.String constructPath(java.lang.String change)
change
is equal
to C:\Jdk, constructPath will return C:\Jdk).
change
- The modification to apply to the pathUtils#beginsWithRoot(String), Utils#getRoot(String)
public static java.lang.String getRoot(java.lang.String path)
path
- The path used to get a root
public static boolean beginsWithRoot(java.lang.String path)
path
- The path to check
public static java.io.File[] listRoots(java.io.File f)
f
- A File
public boolean isHidden(java.io.File file)
file
- Determine if this file is hidden or not
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |