@Test public void testChunkWordSized() { final String input = "zoogam"; final Set<String> expectedOutput = new HashSet<>( Arrays.asList( "zoo", "oog", "gam", "oga", "gam" ) ); final Set<String> output = WordlistUtil.chunkWord( input, 3 ); Assert.assertEquals( expectedOutput, output ); }
static Set<String> chunkWord( final String input, final int chunkSize ) { if ( StringUtil.isEmpty( input ) ) { return Collections.emptySet(); } if ( chunkSize == 0 || chunkSize >= input.length() ) { return Collections.singleton( input ); } final TreeSet<String> testWords = new TreeSet<>(); final int maxIndex = input.length() - chunkSize; for ( int i = 0; i <= maxIndex; i++ ) { final String loopWord = input.substring( i, i + chunkSize ); testWords.add( loopWord ); } return testWords; }
WordlistUtil { static Set<String> chunkWord( final String input, final int chunkSize ) { if ( StringUtil.isEmpty( input ) ) { return Collections.emptySet(); } if ( chunkSize == 0 || chunkSize >= input.length() ) { return Collections.singleton( input ); } final TreeSet<String> testWords = new TreeSet<>(); final int maxIndex = input.length() - chunkSize; for ( int i = 0; i <= maxIndex; i++ ) { final String loopWord = input.substring( i, i + chunkSize ); testWords.add( loopWord ); } return testWords; } }
WordlistUtil { static Set<String> chunkWord( final String input, final int chunkSize ) { if ( StringUtil.isEmpty( input ) ) { return Collections.emptySet(); } if ( chunkSize == 0 || chunkSize >= input.length() ) { return Collections.singleton( input ); } final TreeSet<String> testWords = new TreeSet<>(); final int maxIndex = input.length() - chunkSize; for ( int i = 0; i <= maxIndex; i++ ) { final String loopWord = input.substring( i, i + chunkSize ); testWords.add( loopWord ); } return testWords; }  }
WordlistUtil { static Set<String> chunkWord( final String input, final int chunkSize ) { if ( StringUtil.isEmpty( input ) ) { return Collections.emptySet(); } if ( chunkSize == 0 || chunkSize >= input.length() ) { return Collections.singleton( input ); } final TreeSet<String> testWords = new TreeSet<>(); final int maxIndex = input.length() - chunkSize; for ( int i = 0; i <= maxIndex; i++ ) { final String loopWord = input.substring( i, i + chunkSize ); testWords.add( loopWord ); } return testWords; }   }
WordlistUtil { static Set<String> chunkWord( final String input, final int chunkSize ) { if ( StringUtil.isEmpty( input ) ) { return Collections.emptySet(); } if ( chunkSize == 0 || chunkSize >= input.length() ) { return Collections.singleton( input ); } final TreeSet<String> testWords = new TreeSet<>(); final int maxIndex = input.length() - chunkSize; for ( int i = 0; i <= maxIndex; i++ ) { final String loopWord = input.substring( i, i + chunkSize ); testWords.add( loopWord ); } return testWords; }    }