@Test(expected = SizeLimitExceededException.class) public void testReadRawContent_LimitExceeded() throws Exception { final InputStream is = new ByteArrayInputStream(RandomUtils.nextBytes(30)); HelperUtils.readLimitedAmount(is, 25); }
public static byte[] readLimitedAmount(InputStream data, int maxSize) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(data.available()); final long count = IOUtils.copy(data, bos, 4096); if (count > maxSize) { throw new SizeLimitExceededException("Data stream exceeds size limit of " + maxSize + " bytes"); } return bos.toByteArray(); }
HelperUtils { public static byte[] readLimitedAmount(InputStream data, int maxSize) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(data.available()); final long count = IOUtils.copy(data, bos, 4096); if (count > maxSize) { throw new SizeLimitExceededException("Data stream exceeds size limit of " + maxSize + " bytes"); } return bos.toByteArray(); } }
HelperUtils { public static byte[] readLimitedAmount(InputStream data, int maxSize) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(data.available()); final long count = IOUtils.copy(data, bos, 4096); if (count > maxSize) { throw new SizeLimitExceededException("Data stream exceeds size limit of " + maxSize + " bytes"); } return bos.toByteArray(); } private  HelperUtils(); }
HelperUtils { public static byte[] readLimitedAmount(InputStream data, int maxSize) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(data.available()); final long count = IOUtils.copy(data, bos, 4096); if (count > maxSize) { throw new SizeLimitExceededException("Data stream exceeds size limit of " + maxSize + " bytes"); } return bos.toByteArray(); } private  HelperUtils(); static Long parseTimeString(String input); static String parseStringTs(long ts_Active); static String addZero(int no); static boolean hasCorrectFormat(String input); static void parseEntryValue(Context context, Integer defaultNo); static List<String[]> getLanguageList(String[] availableLanguages, Context context, Result result,
                                                 Messages msg); static boolean checkEmailAddressValidness(String[] mailAddressParts, String[] domainList); static String[] splitMailAddress(String mailAddress); static String getHeaderText(final MimeMessage message); static byte[] readLimitedAmount(InputStream data, int maxSize); }
HelperUtils { public static byte[] readLimitedAmount(InputStream data, int maxSize) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(data.available()); final long count = IOUtils.copy(data, bos, 4096); if (count > maxSize) { throw new SizeLimitExceededException("Data stream exceeds size limit of " + maxSize + " bytes"); } return bos.toByteArray(); } private  HelperUtils(); static Long parseTimeString(String input); static String parseStringTs(long ts_Active); static String addZero(int no); static boolean hasCorrectFormat(String input); static void parseEntryValue(Context context, Integer defaultNo); static List<String[]> getLanguageList(String[] availableLanguages, Context context, Result result,
                                                 Messages msg); static boolean checkEmailAddressValidness(String[] mailAddressParts, String[] domainList); static String[] splitMailAddress(String mailAddress); static String getHeaderText(final MimeMessage message); static byte[] readLimitedAmount(InputStream data, int maxSize);  }