test_class.declarator: testContent
test_class.modifier: private
test_class.original_string: private byte[] testContent;
test_class.type: byte[]
test_class.var_name: testContent
test_class.file: everrest-core/src/test/java/org/everrest/core/impl/provider/IOHelperTest.java
test_class.identifier: IOHelperTest
test_case.body: @Test
      public void buffersGivenInputStreamInMemoryWhenLengthExceedsThreshold() throws Exception {
          InputStream inputStream = new ByteArrayInputStream(testContent);
          InputStream bufferedStream = IOHelper.bufferStream(inputStream, testContent.length - 1);
  
          assertTrue(bufferedStream instanceof FileInputStream);
          try {
              assertArrayEquals(testContent, ByteStreams.toByteArray(bufferedStream));
          } finally {
              bufferedStream.close();
          }
      }
test_case.class_method_signature: IOHelperTest.buffersGivenInputStreamInMemoryWhenLengthExceedsThreshold()
test_case.full_signature: @Test public void buffersGivenInputStreamInMemoryWhenLengthExceedsThreshold()
test_case.identifier: buffersGivenInputStreamInMemoryWhenLengthExceedsThreshold
test_case.invocations: bufferStream assertTrue assertArrayEquals toByteArray close
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void buffersGivenInputStreamInMemoryWhenLengthExceedsThreshold()
focal_class.declarator: DEFAULT_CHARSET_NAME = "UTF-8"
focal_class.modifier: @Deprecated
      private static final
focal_class.original_string: @Deprecated
      private static final String DEFAULT_CHARSET_NAME = "UTF-8";
focal_class.type: String
focal_class.var_name: DEFAULT_CHARSET_NAME
focal_class.declarator: DEFAULT_CHARSET = Charset.forName(DEFAULT_CHARSET_NAME)
focal_class.modifier: @Deprecated
      private static final
focal_class.original_string: @Deprecated
      private static final Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_CHARSET_NAME);
focal_class.type: Charset
focal_class.var_name: DEFAULT_CHARSET
focal_class.file: everrest-core/src/main/java/org/everrest/core/impl/provider/IOHelper.java
focal_class.identifier: IOHelper
focal_class.class_method_signature: IOHelper.IOHelper()
focal_class.full_signature: private  IOHelper()
focal_class.identifier: IOHelper
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  IOHelper()
focal_class.class_method_signature: IOHelper.readString(InputStream in, String cs)
focal_class.full_signature: @Deprecated // Guava used instead in everrest-core, in other modules will be replaced with Guava also public static String readString(InputStream in, String cs)
focal_class.identifier: readString
focal_class.modifiers: @Deprecated // Guava used instead in everrest-core, in other modules will be replaced with Guava also public static
focal_class.parameters: (InputStream in, String cs)
focal_class.return: String
focal_class.signature: String readString(InputStream in, String cs)
focal_class.class_method_signature: IOHelper.writeString(String s, OutputStream out, String cs)
focal_class.full_signature: @Deprecated // Guava used instead in everrest-core, in other modules will be replaced with Guava also public static void writeString(String s, OutputStream out, String cs)
focal_class.identifier: writeString
focal_class.modifiers: @Deprecated // Guava used instead in everrest-core, in other modules will be replaced with Guava also public static
focal_class.parameters: (String s, OutputStream out, String cs)
focal_class.return: void
focal_class.signature: void writeString(String s, OutputStream out, String cs)
focal_class.class_method_signature: IOHelper.bufferStream(InputStream in, int maxMemSize)
focal_class.full_signature: public static InputStream bufferStream(InputStream in, int maxMemSize)
focal_class.identifier: bufferStream
focal_class.modifiers: public static
focal_class.parameters: (InputStream in, int maxMemSize)
focal_class.return: InputStream
focal_class.signature: InputStream bufferStream(InputStream in, int maxMemSize)
focal_method.body: public static InputStream bufferStream(InputStream in, int maxMemSize) throws IOException {
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          byte[] buffer = new byte[8192];
          int bytesNum;
          boolean overflow = false;
          while ((!overflow) && (bytesNum = in.read(buffer)) != -1) {
              bos.write(buffer, 0, bytesNum);
              overflow = bos.size() > maxMemSize;
          }
  
          if (overflow) {
              File file = FileCollector.getInstance().createFile();
              try (FileOutputStream fos = new FileOutputStream(file)) {
                  bos.writeTo(fos);
                  while ((bytesNum = in.read(buffer)) != -1) {
                      fos.write(buffer, 0, bytesNum);
                  }
              }
              return new DeleteOnCloseFIS(file);
          }
          return new ByteArrayInputStream(bos.toByteArray());
      }
focal_method.class_method_signature: IOHelper.bufferStream(InputStream in, int maxMemSize)
focal_method.full_signature: public static InputStream bufferStream(InputStream in, int maxMemSize)
focal_method.identifier: bufferStream
focal_method.invocations: read write size createFile getInstance writeTo read write toByteArray
focal_method.modifiers: public static
focal_method.parameters: (InputStream in, int maxMemSize)
focal_method.return: InputStream
focal_method.signature: InputStream bufferStream(InputStream in, int maxMemSize)