@Test public void testGzipAndBase64Encode() { String input = "{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbbbbbbbb}"; String output = StringExt.gzipAndBase64Encode(input); assertThat(output.length()).isLessThan(input.length()); }
public static String gzipAndBase64Encode(String s) { if (StringExt.isEmpty(s)) { return s; } try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); ) { gzip.write(s.getBytes()); gzip.finish(); return Base64.getEncoder().encodeToString(out.toByteArray()); } catch (Exception e) { throw ExceptionExt.rethrow(e); } }
StringExt { public static String gzipAndBase64Encode(String s) { if (StringExt.isEmpty(s)) { return s; } try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); ) { gzip.write(s.getBytes()); gzip.finish(); return Base64.getEncoder().encodeToString(out.toByteArray()); } catch (Exception e) { throw ExceptionExt.rethrow(e); } } }
StringExt { public static String gzipAndBase64Encode(String s) { if (StringExt.isEmpty(s)) { return s; } try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); ) { gzip.write(s.getBytes()); gzip.finish(); return Base64.getEncoder().encodeToString(out.toByteArray()); } catch (Exception e) { throw ExceptionExt.rethrow(e); } } private  StringExt(); }
StringExt { public static String gzipAndBase64Encode(String s) { if (StringExt.isEmpty(s)) { return s; } try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); ) { gzip.write(s.getBytes()); gzip.finish(); return Base64.getEncoder().encodeToString(out.toByteArray()); } catch (Exception e) { throw ExceptionExt.rethrow(e); } } private  StringExt(); static boolean isNotEmpty(String s); static boolean isEmpty(String s); static String safeTrim(String s); static String nonNull(String value); static String takeUntil(String value, String endMarker); static void applyIfNonEmpty(String value, Consumer<String> consumer); static void runIfEmpty(String value, Runnable action); static void trimAndApplyIfNonEmpty(String value, Consumer<String> consumer); static String concatenate(Collection<String> stringCollection, String delimiter); static String concatenate(T[] array, String delimiter, Function<T, String> mapping); static String concatenate(Object[] array, String delimiter); static String concatenate(E[] array, String delimiter); static String concatenate(Class<E> enumType, String delimiter, Function<E, Boolean> filter); static String getNonEmptyOrDefault(String value, String defaultValue); static Optional<String> firstNonEmpty(String... values); static List<String> trim(List<String> list); static Pattern getCommaSeparator(); static Pattern getDotSeparator(); static Pattern getSemicolonSeparator(); static List<String> splitByComma(String value); static Set<String> splitByCommaIntoSet(String value); static List<String> splitByDot(String value); static E parseEnumIgnoreCase(String enumName, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType, Function<String, List<E>> groupings); static Map<String, A> parseKeyValueList(String text, Pattern entrySeparator, Pattern pairSeparator,
                                                       BiFunction<A, String, A> accumulator); static Map<String, String> parseKeyValueList(String text); static Map<String, Set<String>> parseKeyValuesList(String text); static boolean isAsciiLetter(char c); static boolean isAsciiDigit(char c); static boolean isAsciiLetterOrDigit(char c); static String removeNonAlphanumeric(String text); static int indexOf(Pattern pattern, String text); static String doubleQuotes(String text); static String removeSurroundingQuotes(String text); static String appendToEndIfMissing(String text, String value); static String startWithLowercase(String text); static Optional<Integer> parseInt(String s); static Optional<Long> parseLong(String s); static Optional<Double> parseDouble(String s); static Optional<List<Duration>> parseDurationMsList(String s); static String gzipAndBase64Encode(String s); static Either<String, IllegalArgumentException> nameFromJavaBeanGetter(String getterName); }
StringExt { public static String gzipAndBase64Encode(String s) { if (StringExt.isEmpty(s)) { return s; } try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(out); ) { gzip.write(s.getBytes()); gzip.finish(); return Base64.getEncoder().encodeToString(out.toByteArray()); } catch (Exception e) { throw ExceptionExt.rethrow(e); } } private  StringExt(); static boolean isNotEmpty(String s); static boolean isEmpty(String s); static String safeTrim(String s); static String nonNull(String value); static String takeUntil(String value, String endMarker); static void applyIfNonEmpty(String value, Consumer<String> consumer); static void runIfEmpty(String value, Runnable action); static void trimAndApplyIfNonEmpty(String value, Consumer<String> consumer); static String concatenate(Collection<String> stringCollection, String delimiter); static String concatenate(T[] array, String delimiter, Function<T, String> mapping); static String concatenate(Object[] array, String delimiter); static String concatenate(E[] array, String delimiter); static String concatenate(Class<E> enumType, String delimiter, Function<E, Boolean> filter); static String getNonEmptyOrDefault(String value, String defaultValue); static Optional<String> firstNonEmpty(String... values); static List<String> trim(List<String> list); static Pattern getCommaSeparator(); static Pattern getDotSeparator(); static Pattern getSemicolonSeparator(); static List<String> splitByComma(String value); static Set<String> splitByCommaIntoSet(String value); static List<String> splitByDot(String value); static E parseEnumIgnoreCase(String enumName, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType); static List<E> parseEnumListIgnoreCase(String enumNames, Class<E> enumType, Function<String, List<E>> groupings); static Map<String, A> parseKeyValueList(String text, Pattern entrySeparator, Pattern pairSeparator,
                                                       BiFunction<A, String, A> accumulator); static Map<String, String> parseKeyValueList(String text); static Map<String, Set<String>> parseKeyValuesList(String text); static boolean isAsciiLetter(char c); static boolean isAsciiDigit(char c); static boolean isAsciiLetterOrDigit(char c); static String removeNonAlphanumeric(String text); static int indexOf(Pattern pattern, String text); static String doubleQuotes(String text); static String removeSurroundingQuotes(String text); static String appendToEndIfMissing(String text, String value); static String startWithLowercase(String text); static Optional<Integer> parseInt(String s); static Optional<Long> parseLong(String s); static Optional<Double> parseDouble(String s); static Optional<List<Duration>> parseDurationMsList(String s); static String gzipAndBase64Encode(String s); static Either<String, IllegalArgumentException> nameFromJavaBeanGetter(String getterName); final static Pattern COMMA_SPLIT_RE; final static Pattern DOT_SPLIT_RE; final static Pattern SEMICOLON_SPLIT_RE; final static Pattern COLON_SPLIT_RE; final static Pattern EQUAL_SPLIT_RE; }