morfologik.util
Class FileUtils

java.lang.Object
  extended by morfologik.util.FileUtils

public final class FileUtils
extends java.lang.Object

Utility functions.


Method Summary
static void assertExists(java.io.File fsaFile, boolean requireFile, boolean requireDirectory)
          Checks if the given file exists.
static void close(java.io.Closeable... closeables)
          Force any non-null closeables.
static byte readByte(java.io.InputStream in)
          Read exactly one byte from the input stream.
static byte[] readFully(java.io.InputStream stream)
          Reads all bytes from an input stream (until EOF).
static void readFully(java.io.InputStream in, byte[] array)
          Read enough bytes to fill array If there are not enough bytes, throw an exception.
static int readInt(java.io.InputStream in)
          Read exactly 4 bytes from the input stream.
static short readShort(java.io.InputStream in)
          Read exactly 2 bytes from the input stream.
static void writeInt(java.io.OutputStream os, int v)
           
static void writeShort(java.io.OutputStream os, short v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertExists

public static void assertExists(java.io.File fsaFile,
                                boolean requireFile,
                                boolean requireDirectory)
                         throws java.io.IOException
Checks if the given file exists.

Throws:
java.io.IOException

close

public static void close(java.io.Closeable... closeables)
Force any non-null closeables.


readFully

public static byte[] readFully(java.io.InputStream stream)
                        throws java.io.IOException
Reads all bytes from an input stream (until EOF).

Throws:
java.io.IOException

readFully

public static void readFully(java.io.InputStream in,
                             byte[] array)
                      throws java.io.IOException
Read enough bytes to fill array If there are not enough bytes, throw an exception.

Throws:
java.io.IOException

readInt

public static int readInt(java.io.InputStream in)
                   throws java.io.IOException
Read exactly 4 bytes from the input stream.

Throws:
java.io.IOException

writeInt

public static void writeInt(java.io.OutputStream os,
                            int v)
                     throws java.io.IOException
Throws:
java.io.IOException

readShort

public static short readShort(java.io.InputStream in)
                       throws java.io.IOException
Read exactly 2 bytes from the input stream.

Throws:
java.io.IOException

readByte

public static byte readByte(java.io.InputStream in)
                     throws java.io.IOException
Read exactly one byte from the input stream.

Throws:
java.io.EOFException - if EOF is reached.
java.io.IOException

writeShort

public static void writeShort(java.io.OutputStream os,
                              short v)
                       throws java.io.IOException
Throws:
java.io.IOException