com.sun.slamd.misc
Class SplitFile

java.lang.Object
  extended bycom.sun.slamd.misc.SplitFile

public class SplitFile
extends java.lang.Object

This program provides a mechanism to easily split a text file into multiple files based on a number of criteria (specific number of files, number of lines per file, or number of bytes per file).


Field Summary
static int SPLIT_TYPE_NUM_BYTES
          The split type that indicates the file should be split up so that there are a maximum number of bytes per file.
static int SPLIT_TYPE_NUM_FILES
          The split type that indicates the file should be split up into a specific number of files.
static int SPLIT_TYPE_NUM_FILES_PRESERVE_ORDER
          The split type that indicates the file should be split up into a specific number of files.
static int SPLIT_TYPE_NUM_LINES
          The split type that indicates the file should be split up so that there are a maximum number of lines per file.
 
Constructor Summary
SplitFile(java.lang.String[] args)
          Creates a new instance of this program and coordinates the process of splitting the file.
 
Method Summary
 int countLines()
          Counts the number of lines in the input file.
 void displayUsage()
          Prints usage information for this program to standard error.
static void main(java.lang.String[] args)
          The main method for this program, which simply invokes the constructor.
 void splitByMaxBytes()
          Splits the input file into a number of output files based on the number of bytes per file.
 void splitByMaxLines()
          Splits the input file into a number of output files based on the number of lines per file.
 void splitToNumFiles()
          Splits the input file into the specified number of output files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPLIT_TYPE_NUM_FILES

public static final int SPLIT_TYPE_NUM_FILES
The split type that indicates the file should be split up into a specific number of files. The order of the original file will not be preserved.

See Also:
Constant Field Values

SPLIT_TYPE_NUM_FILES_PRESERVE_ORDER

public static final int SPLIT_TYPE_NUM_FILES_PRESERVE_ORDER
The split type that indicates the file should be split up into a specific number of files. The order of the original file will be preserved.

See Also:
Constant Field Values

SPLIT_TYPE_NUM_LINES

public static final int SPLIT_TYPE_NUM_LINES
The split type that indicates the file should be split up so that there are a maximum number of lines per file.

See Also:
Constant Field Values

SPLIT_TYPE_NUM_BYTES

public static final int SPLIT_TYPE_NUM_BYTES
The split type that indicates the file should be split up so that there are a maximum number of bytes per file.

See Also:
Constant Field Values
Constructor Detail

SplitFile

public SplitFile(java.lang.String[] args)
Creates a new instance of this program and coordinates the process of splitting the file.

Parameters:
args - The command line arguments provided to the program.
Method Detail

main

public static void main(java.lang.String[] args)
The main method for this program, which simply invokes the constructor.

Parameters:
args - The command line arguments provided to the program.

countLines

public int countLines()
               throws java.io.IOException
Counts the number of lines in the input file.

Returns:
The number of lines in the input file.
Throws:
java.io.IOException - If a problem occurs while counting the lines in the file.

splitToNumFiles

public void splitToNumFiles()
                     throws java.io.IOException
Splits the input file into the specified number of output files.

Throws:
java.io.IOException - If a problem occurs while splitting the file.

splitByMaxLines

public void splitByMaxLines()
                     throws java.io.IOException
Splits the input file into a number of output files based on the number of lines per file.

Throws:
java.io.IOException - If a problem occurs while splitting the file.

splitByMaxBytes

public void splitByMaxBytes()
                     throws java.io.IOException
Splits the input file into a number of output files based on the number of bytes per file.

Throws:
java.io.IOException - If a problem occurs while splitting the file.

displayUsage

public void displayUsage()
Prints usage information for this program to standard error.