Package com.xmultra.util

Examples of com.xmultra.util.StringSplitResult


            String tail              = "";
            String fileName          = "";
            List stringList          = new ArrayList();
            List startMarkList       = new ArrayList();
            List endMarkList         = new ArrayList();
            StringSplitResult result = null;
            String splitOutString    = null;
            String startMark         = null;
            String endMark           = null;
            String headerLine        = null;
            int headerLines          = 0;

            if (this.copyHeaderLine) {
                ReadFileResults readResults = readLinesFromFile(bufReader, 1);
                headerLine = readResults.output;
                headerLines = 1;

                if (readResults.endOfFile) {
                    return "Could not split up: ";
                }
            }

            /*
             * Only a portion of the file to be split is read at a time. This
             * is to prevent creating giant Strings (and sucking up large
             * amounts of memory) if large files are read.
             *
             * This loop reads a chunk of the 'fileToSplit', splits it up,
             * and then gets the next chunk. Various conditions cause the
             * loop to exit but mainly this loops exits when all data is
             * read and split up.
             */
            while (true) {
                ReadFileResults readResults = null;
               
                if (this.splitByLines) {
                    readResults =
                        readLinesFromFile(bufReader, outputFileSizeMaxLines - headerLines);
                }
                else {
                    readResults = readBytesFromFile(bufReader, this.readBuffer);
                }

                String readString = readResults.output;

                // If there was an error...
                if (readString == null) break;

                // If nothing to split...
                if (readString.equals("") && tail.equals("")) break;

                // Keep track of how many split-out files so far for this input.
                // Don't increment count if file is too short to be split.
                if (!readResults.endOfFile || splitCount > 0) {
                    splitCount++;
                }

                if (splitByLines) {
                    fileName = getFileName(fileToSplit, splitCount, readString);
                    writeSplitFile(fileName, readString, headerLine);

                    if (readResults.endOfFile) {
                        break;
                    }
                }
                else {
                    // Add the previous tail to the readString.
                    String stringToSplit = tail + readString;

                    // Split the string up.
                    result = stringSplitter.splitString(startPattern,
                                                        endPattern,
                                                        this.outputStartAndEndMarks,
                                                        stringToSplit);

                    // Get the list split out strings and write them out to files.
                    stringList = result.getSplitList();
                    startMarkList = result.getStartMarkList();
                    endMarkList = result.getEndMarkList();

                    for (int i = 0; i < stringList.size(); i++) {

                        splitOutString = (String)stringList.get(i);

View Full Code Here

TOP

Related Classes of com.xmultra.util.StringSplitResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.