Hitman
Class IOUtil

java.lang.Object
  extended by Hitman.IOUtil

public class IOUtil
extends java.lang.Object

IO utility functions


Constructor Summary
IOUtil()
           
 
Method Summary
static java.lang.String exec(java.lang.String cmd)
          Execute a command (system() equivalent)
static java.lang.String getExt(java.io.File file)
          Split the extension from a filename.
static java.lang.String getFileType(java.io.File file)
          Determine the MIMEtype of a file (UNIX-specific function).
static java.lang.String slurp(java.io.Reader in)
          Read a String from a Reader until EOF
static java.lang.String slurp(java.io.Reader r, byte __unused)
           
static java.lang.String slurp(java.io.Reader in, long len)
          Read a string from a Reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtil

public IOUtil()
Method Detail

slurp

public static java.lang.String slurp(java.io.Reader in,
                                     long len)
                              throws java.io.IOException
Read a string from a Reader.

Parameters:
in - Reader to read from
len - Number of bytes to read
Returns:
The String
Throws:
java.io.IOException

slurp

public static java.lang.String slurp(java.io.Reader in)
                              throws java.io.IOException
Read a String from a Reader until EOF

Parameters:
in - Reader to read from
Returns:
The String
Throws:
java.io.IOException

slurp

public static java.lang.String slurp(java.io.Reader r,
                                     byte __unused)
                              throws java.io.IOException
Throws:
java.io.IOException

exec

public static java.lang.String exec(java.lang.String cmd)
                             throws java.io.IOException
Execute a command (system() equivalent)

Parameters:
cmd - The command to execute
Returns:
Everything that was written to stdout and stderr by the executed process
Throws:
java.io.IOException

getFileType

public static java.lang.String getFileType(java.io.File file)
                                    throws java.io.IOException
Determine the MIMEtype of a file (UNIX-specific function).

Parameters:
file - The relevant file
Returns:
MIMEtype as returned by file(1)
Throws:
java.io.IOException

getExt

public static java.lang.String getExt(java.io.File file)
Split the extension from a filename.

Parameters:
file - The relevant file
Returns:
The file's extension