|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nih.nlm.util.SystemToolkit
Utility toolkit.
Constructor Summary | |
SystemToolkit()
|
Method Summary | |
static void |
copy(File in,
File out)
Copies the input file to the output file. |
static void |
copy(File in,
File out,
ProgressMonitor pm)
Copies the input file to the output file. |
static String[] |
getIndexWords(String[] words)
Lowercases words and returns the list sorted and uniqed. |
static String[] |
getZipEntries(String zip_file_name)
Returns a list of zip entry file names. |
static InputStream |
getZipInputStream(String zf,
String ze)
Returns an InputStream for the ZipEntry in
the specified ZipFile . |
static boolean |
isStopWord(String word)
Checks whether the word is one of the stop words. |
static void |
main(String[] s)
|
static String |
md5(File file)
Returns the MD5 value for the given File . |
static String |
md5(File file,
ProgressMonitor pm)
Returns the MD5 value for the given File . |
static String |
md5(String text)
Compute the MD5 hash of a string. |
static String |
md5(String text,
String char_encoding)
Compute the MD5 hash of a string using the specified character encoding. |
static String |
md5CrossPlatform(File file)
Returns the MD5 value for the given File . |
static String |
md5CrossPlatform(File file,
ProgressMonitor pm)
Returns the MD5 value for the given File . |
static String[][] |
readFieldedFile(File file,
String delim)
Reads the fielded file into a two-dimensional string array. |
static String[][] |
readFieldedReader(BufferedReader in,
String delim)
Reads the fielded file into a two-dimensional string array. |
static String |
readLine(RandomAccessFile raf,
String char_set)
Reads and returns a line from the RandomAccessFile using
the specified character set. |
static String |
removeLinks(String html)
Removes any links within a specified HTML document. |
static String |
removeTags(String html)
Returns an HTML document stripped of its tags. |
static long |
seekstr(RandomAccessFile raf,
String search_string,
String char_set)
Seek to the location in the RandomAccessFile where the first
line of text starts with the search string. |
static void |
sort(String filename)
Sort the specified file. |
static void |
sort(String filename,
boolean unique)
Sort the specified file (optionally uniquely). |
static void |
sort(String filename,
boolean unique,
ProgressMonitor pm)
Sort the specified file (optionally uniquely). |
static void |
sort(String filename,
Comparator comp)
Sort the specified file using the specified Comparator . |
static void |
sort(String filename,
Comparator comp,
boolean unique)
Sort the specified file using the specified Comparator and
optionally sort uniquely. |
static void |
sort(String filename,
Comparator comp,
boolean unique,
ProgressMonitor pm)
Sort the specified file using the specified Comparator and
optionally sort uniquely. |
static void |
sort(String filename,
ProgressMonitor pm)
Sort the specified file. |
static String |
toHexString(byte[] v)
Converts a byte [] to a hex string. |
static void |
unzip(String zip_file,
String output_dir,
String archive_subdir,
ProgressMonitor pm)
Unzips the specified file into the specified directory using. |
static void |
unzip(String unzip_cmd,
String zip_file,
String output_dir,
String archive_subdir,
ProgressMonitor pm)
Unzips the specified file into the specified directory using the specified operating system command. |
static void |
unzipInternal(String zip_file,
String output_dir,
String archive_subdir)
Unzips the specified file into the specified directory using pure java. |
static void |
unzipInternal(String zip_file,
String output_dir,
String archive_subdir,
ProgressMonitor pm)
Unzips the specified file into the specified directory using pure java. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SystemToolkit()
Method Detail |
public static boolean isStopWord(String word)
word
- lowercase string
true
if the word is a stop word, false
otherwisepublic static String[] getIndexWords(String[] words)
words
- words from a string
public static void copy(File in, File out) throws IOException
in
- the input File
out
- the output File
IOException
public static void copy(File in, File out, ProgressMonitor pm) throws IOException
in
- the input File
out
- the output File
pm
- the ProgressMonitor
IOException
public static String md5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException
text
- the value to compute a hash for
NoSuchAlgorithmException
- if failed due to no such algorithm
UnsupportedEncodingException
- if failed due to unsupported encodingpublic static String md5(String text, String char_encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException
text
- the value to compute a hash forchar_encoding
- a character encoding (e.g. "UTF-8")
NoSuchAlgorithmException
- if failed due to no such algorithm
UnsupportedEncodingException
- if failed due to unsupported encodingpublic static String md5(File file) throws IOException, NoSuchAlgorithmException
File
.
file
- for which to determine the MD5
IOException
NoSuchAlgorithmException
public static String md5(File file, ProgressMonitor pm) throws IOException, NoSuchAlgorithmException
File
.
file
- for which to determine the MD5pm
- an optional progress monitor to track whether operation should be cancelled
IOException
NoSuchAlgorithmException
public static String md5CrossPlatform(File file) throws IOException, NoSuchAlgorithmException
File
.
file
- for which to determine the MD5
IOException
NoSuchAlgorithmException
public static String md5CrossPlatform(File file, ProgressMonitor pm) throws IOException, NoSuchAlgorithmException
File
.
file
- for which to determine the MD5pm
- an optional progress monitor to track whether operation should be cancelled
IOException
NoSuchAlgorithmException
public static String toHexString(byte[] v)
[]
to a hex string.
v
- the byte[]
public static String removeTags(String html)
html
- an html document
public static String removeLinks(String html)
html
- an html document
public static void unzip(String zip_file, String output_dir, String archive_subdir, ProgressMonitor pm) throws IOException
zip_file
- the zip file nameoutput_dir
- the directory to unzip toarchive_subdir
- the portion of the archive to extractpm
- the progrss monitor
IOException
public static void unzip(String unzip_cmd, String zip_file, String output_dir, String archive_subdir, ProgressMonitor pm) throws IOException
unzip_cmd
- the OS command to use to unzipzip_file
- the zip file nameoutput_dir
- the directory to unzip toarchive_subdir
- the portion of the archive to extractpm
- the progrss monitor
IOException
public static void unzipInternal(String zip_file, String output_dir, String archive_subdir) throws IOException
zip_file
- the ZipFile
name to unzipoutput_dir
- the output directoryarchive_subdir
- indicates what to unzip, (use * for everything)
IOException
- if anything goes wrong manipulating the files.public static void unzipInternal(String zip_file, String output_dir, String archive_subdir, ProgressMonitor pm) throws IOException
zip_file
- the ZipFile
name to unzipoutput_dir
- the output directoryarchive_subdir
- indicates what to unzip, (use * for everything)pm
- the ProgressMonitor
used to track progress.
IOException
- if anything goes wrong manipulating the files.public static long seekstr(RandomAccessFile raf, String search_string, String char_set) throws IOException
RandomAccessFile
where the first
line of text starts with the search string. This implements a
binary search function in a file (like the UNIX look
command).
raf
- the RandomAccessFile
to searchsearch_string
- the search stringchar_set
- the character set to use for the search_string
IOException
- if anything goes wrongpublic static String readLine(RandomAccessFile raf, String char_set) throws IOException
RandomAccessFile
using
the specified character set.
raf
- the RandomAccessFile
char_set
- the character set
RandomAccessFile
in the specified character set
IOException
public static InputStream getZipInputStream(String zf, String ze) throws IOException
InputStream
for the ZipEntry
in
the specified ZipFile
. Uses the native unzip program
found in the system "unzip.path" property.
zf
- the ZipFile
ze
- the ZipEntry
InputStream
IOException
- if anything goes wrongpublic static String[] getZipEntries(String zip_file_name) throws IOException
zip_file_name
- the zip file name
IOException
public static void main(String[] s)
public static void sort(String filename) throws IOException
filename
- the file to sort
IOException
- if failed to sortpublic static void sort(String filename, ProgressMonitor pm) throws IOException
filename
- the file to sortpm
- ProgressMonitor
IOException
- if failed to sortpublic static void sort(String filename, boolean unique) throws IOException
filename
- the file to sortunique
- a boolean
which detemine duplicate lines
IOException
- if failed to sortpublic static void sort(String filename, boolean unique, ProgressMonitor pm) throws IOException
filename
- the file to sortunique
- a boolean
which detemine duplicate linespm
- ProgressMonitor
IOException
- if failed to sortpublic static void sort(String filename, Comparator comp) throws IOException
Comparator
.
filename
- the file to sortcomp
- the Comparator
IOException
- if failed to sortpublic static void sort(String filename, Comparator comp, boolean unique) throws IOException
Comparator
and
optionally sort uniquely.
filename
- the file to sortcomp
- the Comparator
unique
- a boolean
which detemine duplicate lines
IOException
- if failed to sortpublic static void sort(String filename, Comparator comp, boolean unique, ProgressMonitor pm) throws IOException
Comparator
and
optionally sort uniquely.
filename
- the file to sortcomp
- the Comparator
unique
- a boolean
which detemine duplicate linespm
- a ProgressMonitor
IOException
- if failed to sortpublic static String[][] readFieldedFile(File file, String delim) throws IOException
file
- the file to readdelim
- the field separator in the file
String
[][]
of the lines/fields
IOException
- if anything goes wrongpublic static String[][] readFieldedReader(BufferedReader in, String delim) throws IOException
in
- the BufferedReader
inputdelim
- the field separator in the file
String
[][]
of the lines/fields
IOException
- if anything goes wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |