@Test public void testCompressText() throws Exception { Assert.assertEquals("【悲報】", StringUtil.compressText("【悲報】\n【悲報】\n【悲報】\n【悲報】")); Assert.assertEquals("【悲報】", StringUtil.compressText("【悲報】 \n【悲報】\n【悲報】 \n【悲報】 ")); Assert.assertNull(StringUtil.compressText("【悲報】\n【悲報】\n【悲報】")); Assert.assertEquals("[ﾟдﾟ]", StringUtil.compressText("[ﾟдﾟ]\n[ﾟдﾟ]\n[ﾟдﾟ]\n[ﾟдﾟ]")); Assert.assertNull(StringUtil.compressText("[ﾟдﾟ]\n[ﾟдﾟ]\n[ﾟдﾟ]")); Assert.assertEquals("↓", StringUtil.compressText("わかる\n↓\nウケる\n↓\n神\n↓\nわかる\n↓\nウケる\n↓\n神")); }
@Nullable public static String compressText(String text) { String repeatedSequence = ""; int maxRepeat = 0; String[] split = text.split("\n"); for (String s1 : split) { int repeat = 0; for (String s2 : split) { if (!"".equals(s2.trim()) && s1.trim().equals(s2.trim())) { ++repeat; } } if ((maxRepeat = Math.max(maxRepeat, repeat)) == repeat) { repeatedSequence = s1.trim(); } } if (maxRepeat >= TOO_MANY_REPEAT) { return repeatedSequence; } else { return null; } }
StringUtil { @Nullable public static String compressText(String text) { String repeatedSequence = ""; int maxRepeat = 0; String[] split = text.split("\n"); for (String s1 : split) { int repeat = 0; for (String s2 : split) { if (!"".equals(s2.trim()) && s1.trim().equals(s2.trim())) { ++repeat; } } if ((maxRepeat = Math.max(maxRepeat, repeat)) == repeat) { repeatedSequence = s1.trim(); } } if (maxRepeat >= TOO_MANY_REPEAT) { return repeatedSequence; } else { return null; } } }
StringUtil { @Nullable public static String compressText(String text) { String repeatedSequence = ""; int maxRepeat = 0; String[] split = text.split("\n"); for (String s1 : split) { int repeat = 0; for (String s2 : split) { if (!"".equals(s2.trim()) && s1.trim().equals(s2.trim())) { ++repeat; } } if ((maxRepeat = Math.max(maxRepeat, repeat)) == repeat) { repeatedSequence = s1.trim(); } } if (maxRepeat >= TOO_MANY_REPEAT) { return repeatedSequence; } else { return null; } }  }
StringUtil { @Nullable public static String compressText(String text) { String repeatedSequence = ""; int maxRepeat = 0; String[] split = text.split("\n"); for (String s1 : split) { int repeat = 0; for (String s2 : split) { if (!"".equals(s2.trim()) && s1.trim().equals(s2.trim())) { ++repeat; } } if ((maxRepeat = Math.max(maxRepeat, repeat)) == repeat) { repeatedSequence = s1.trim(); } } if (maxRepeat >= TOO_MANY_REPEAT) { return repeatedSequence; } else { return null; } }  static String generateKey(String key); static String generateKeySimple(String key); static String generateKeyHash(String key); static StringBuilder format02d(StringBuilder s, int num); static String formatDate(Date date); static String formatDate(long timeInMillis); static String getVersionInfo(Context context); @Nullable static String compressText(String text); }
StringUtil { @Nullable public static String compressText(String text) { String repeatedSequence = ""; int maxRepeat = 0; String[] split = text.split("\n"); for (String s1 : split) { int repeat = 0; for (String s2 : split) { if (!"".equals(s2.trim()) && s1.trim().equals(s2.trim())) { ++repeat; } } if ((maxRepeat = Math.max(maxRepeat, repeat)) == repeat) { repeatedSequence = s1.trim(); } } if (maxRepeat >= TOO_MANY_REPEAT) { return repeatedSequence; } else { return null; } }  static String generateKey(String key); static String generateKeySimple(String key); static String generateKeyHash(String key); static StringBuilder format02d(StringBuilder s, int num); static String formatDate(Date date); static String formatDate(long timeInMillis); static String getVersionInfo(Context context); @Nullable static String compressText(String text); static final char[] HEX_DIGITS; }