@Test public void autoSplitThisStartSpace() { byte[] letters = bytes( " This is a string" ); byte[][] splitted = ByteScanner.split( letters, ' ' ); assertEquals( 5, splitted.length ); assertEquals( 0, splitted[ 0 ].length ); assertArrayEquals( bytes( "This" ), splitted[ 1 ] ); assertArrayEquals( bytes( "is" ), splitted[ 2 ] ); assertArrayEquals( bytes( "a" ), splitted[ 3 ] ); assertArrayEquals( bytes( "string" ), splitted[ 4 ] ); assertArrayEquals( new byte[][]{ bytes( "" ), bytes( "This" ), bytes( "is" ), bytes( "a" ), bytes( "string" ) }, splitted ); }
public static byte[][] split( final byte[] inputArray, final int split ) { byte[][] results = new byte[ 16 ][]; int resultIndex = 0; int startCurrentLineIndex = 0; int currentLineLength = 1; byte c = '\u0000'; int index = 0; for (; index < inputArray.length; index++, currentLineLength++ ) { c = inputArray[ index ]; if ( c == split ) { if ( resultIndex == results.length ) { results = _grow( results ); } results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); startCurrentLineIndex = index + 1; currentLineLength = 0; resultIndex++; } } if ( c != split ) { results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); resultIndex++; } int actualLength = resultIndex; if ( actualLength < results.length ) { final int newSize = results.length - actualLength; results = __shrink( results, newSize ); } return results; }
ByteScanner { public static byte[][] split( final byte[] inputArray, final int split ) { byte[][] results = new byte[ 16 ][]; int resultIndex = 0; int startCurrentLineIndex = 0; int currentLineLength = 1; byte c = '\u0000'; int index = 0; for (; index < inputArray.length; index++, currentLineLength++ ) { c = inputArray[ index ]; if ( c == split ) { if ( resultIndex == results.length ) { results = _grow( results ); } results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); startCurrentLineIndex = index + 1; currentLineLength = 0; resultIndex++; } } if ( c != split ) { results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); resultIndex++; } int actualLength = resultIndex; if ( actualLength < results.length ) { final int newSize = results.length - actualLength; results = __shrink( results, newSize ); } return results; } }
ByteScanner { public static byte[][] split( final byte[] inputArray, final int split ) { byte[][] results = new byte[ 16 ][]; int resultIndex = 0; int startCurrentLineIndex = 0; int currentLineLength = 1; byte c = '\u0000'; int index = 0; for (; index < inputArray.length; index++, currentLineLength++ ) { c = inputArray[ index ]; if ( c == split ) { if ( resultIndex == results.length ) { results = _grow( results ); } results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); startCurrentLineIndex = index + 1; currentLineLength = 0; resultIndex++; } } if ( c != split ) { results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); resultIndex++; } int actualLength = resultIndex; if ( actualLength < results.length ) { final int newSize = results.length - actualLength; results = __shrink( results, newSize ); } return results; }  }
ByteScanner { public static byte[][] split( final byte[] inputArray, final int split ) { byte[][] results = new byte[ 16 ][]; int resultIndex = 0; int startCurrentLineIndex = 0; int currentLineLength = 1; byte c = '\u0000'; int index = 0; for (; index < inputArray.length; index++, currentLineLength++ ) { c = inputArray[ index ]; if ( c == split ) { if ( resultIndex == results.length ) { results = _grow( results ); } results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); startCurrentLineIndex = index + 1; currentLineLength = 0; resultIndex++; } } if ( c != split ) { results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); resultIndex++; } int actualLength = resultIndex; if ( actualLength < results.length ) { final int newSize = results.length - actualLength; results = __shrink( results, newSize ); } return results; }  static boolean isDigits( final char[] inputArray ); static boolean hasDecimalChar( byte[] chars, boolean negative ); static byte[][] splitExact( final byte[] inputArray,
                                       final int split, final int resultsArrayLength ); static byte[][] splitExact( final byte[] inputArray,
                                       final int resultsArrayLength, int... delims ); static byte[][] split( final byte[] inputArray,
                                  final int split ); static byte[][] splitByChars( final byte[] inputArray,
                                         char... delims ); static byte[][] splitByCharsFromToDelims( final byte[] inputArray, int from, int to,
                                                     final byte... delims ); static byte[][] splitByCharsNoneEmpty( byte[] inputArray,
                                                  char... delims ); static byte[][] splitByCharsNoneEmpty( final byte[] inputArray, int from, int to,
                                                  final byte... delims ); static byte[][] compact( byte[][] array ); static boolean isInteger( byte[] digitChars, int offset, int len
                                      ); static boolean isLong( byte[] digitChars, int offset, int len
                                   ); static int parseInt( byte[] digitChars ); static int parseIntFromTo( byte[] digitChars, int offset, int to ); static int parseIntIgnoreDot( byte[] digitChars, int offset, int len ); static long parseLong( byte[] digitChars, int offset, int len ); static long parseLongIgnoreDot( byte[] digitChars, int offset, int len ); static Number parseJsonNumber( byte[] buffer ); static Number parseJsonNumber( byte[] buffer, int from, int to ); static Number parseJsonNumber( byte[] buffer, int from, int max, int size[] ); static long parseLongFromTo( byte[] digitChars, int offset, int to ); static int parseIntFromToIgnoreDot( byte[] digitChars, int offset, int to ); static long parseLongFromToIgnoreDot( byte[] digitChars, int offset, int to ); static float parseFloat( byte[] buffer, int from, int to ); static double parseDouble( byte[] buffer ); static double parseDouble( byte[] buffer, int from, int to ); static double simpleDouble( byte[] buffer, boolean simple,  int digitsPastPoint, int startIndex, int endIndex ); static int skipWhiteSpace( byte [] array, int index ); static int skipWhiteSpace( byte [] array, int index, final int length ); static byte[] readNumber( byte[] array, int idx ); static byte[] readNumber( byte[] array, int idx, final int len ); static int skipWhiteSpaceFast( byte [] array ); static int skipWhiteSpaceFast( byte [] array, int index ); static void encodeByteIntoTwoAsciiCharBytes( final int decoded, final byte[] encoded ); static String errorDetails( String message, byte[] array, int index, int ch ); static boolean hasEscapeChar(byte []array, int index, int[] indexHolder); static int findEndQuote(final byte[] array,  int index); static int findEndQuoteUTF8(final byte[] array,  int index); static boolean hasEscapeCharUTF8(byte []array, int index, int[] indexHolder); }
ByteScanner { public static byte[][] split( final byte[] inputArray, final int split ) { byte[][] results = new byte[ 16 ][]; int resultIndex = 0; int startCurrentLineIndex = 0; int currentLineLength = 1; byte c = '\u0000'; int index = 0; for (; index < inputArray.length; index++, currentLineLength++ ) { c = inputArray[ index ]; if ( c == split ) { if ( resultIndex == results.length ) { results = _grow( results ); } results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); startCurrentLineIndex = index + 1; currentLineLength = 0; resultIndex++; } } if ( c != split ) { results[ resultIndex ] = Byt.copy( inputArray, startCurrentLineIndex, currentLineLength - 1 ); resultIndex++; } int actualLength = resultIndex; if ( actualLength < results.length ) { final int newSize = results.length - actualLength; results = __shrink( results, newSize ); } return results; }  static boolean isDigits( final char[] inputArray ); static boolean hasDecimalChar( byte[] chars, boolean negative ); static byte[][] splitExact( final byte[] inputArray,
                                       final int split, final int resultsArrayLength ); static byte[][] splitExact( final byte[] inputArray,
                                       final int resultsArrayLength, int... delims ); static byte[][] split( final byte[] inputArray,
                                  final int split ); static byte[][] splitByChars( final byte[] inputArray,
                                         char... delims ); static byte[][] splitByCharsFromToDelims( final byte[] inputArray, int from, int to,
                                                     final byte... delims ); static byte[][] splitByCharsNoneEmpty( byte[] inputArray,
                                                  char... delims ); static byte[][] splitByCharsNoneEmpty( final byte[] inputArray, int from, int to,
                                                  final byte... delims ); static byte[][] compact( byte[][] array ); static boolean isInteger( byte[] digitChars, int offset, int len
                                      ); static boolean isLong( byte[] digitChars, int offset, int len
                                   ); static int parseInt( byte[] digitChars ); static int parseIntFromTo( byte[] digitChars, int offset, int to ); static int parseIntIgnoreDot( byte[] digitChars, int offset, int len ); static long parseLong( byte[] digitChars, int offset, int len ); static long parseLongIgnoreDot( byte[] digitChars, int offset, int len ); static Number parseJsonNumber( byte[] buffer ); static Number parseJsonNumber( byte[] buffer, int from, int to ); static Number parseJsonNumber( byte[] buffer, int from, int max, int size[] ); static long parseLongFromTo( byte[] digitChars, int offset, int to ); static int parseIntFromToIgnoreDot( byte[] digitChars, int offset, int to ); static long parseLongFromToIgnoreDot( byte[] digitChars, int offset, int to ); static float parseFloat( byte[] buffer, int from, int to ); static double parseDouble( byte[] buffer ); static double parseDouble( byte[] buffer, int from, int to ); static double simpleDouble( byte[] buffer, boolean simple,  int digitsPastPoint, int startIndex, int endIndex ); static int skipWhiteSpace( byte [] array, int index ); static int skipWhiteSpace( byte [] array, int index, final int length ); static byte[] readNumber( byte[] array, int idx ); static byte[] readNumber( byte[] array, int idx, final int len ); static int skipWhiteSpaceFast( byte [] array ); static int skipWhiteSpaceFast( byte [] array, int index ); static void encodeByteIntoTwoAsciiCharBytes( final int decoded, final byte[] encoded ); static String errorDetails( String message, byte[] array, int index, int ch ); static boolean hasEscapeChar(byte []array, int index, int[] indexHolder); static int findEndQuote(final byte[] array,  int index); static int findEndQuoteUTF8(final byte[] array,  int index); static boolean hasEscapeCharUTF8(byte []array, int index, int[] indexHolder);  }