理解できないメモリの問題が発生しています。私は次の場合があります
ケース1
public  byte[] getBytes(InputStream is) throws IOException {
            int len;
            int size = 1024;
            byte[] buf;
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              buf = new byte[size];
              while ((len = is.read(buf, 0, size)) != -1)
              {
                bos.write(buf, 0, len);
              }
              buf = bos.toByteArray();
            return buf;
          }
Public void dosomething()
{
 //instructions
InputStream is = new ByteArrayInputStream(getBytes(bodyPart.getInputStream()));
}
エラーなしで正常に動作します
でも、これ
ケース2
Public void dosomething()
{
 //instructions
ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    int len;
                    int size = 1024;
                    byte[] bufferFichierEntree = new byte[size];
                     while ((len = bodyPart.getInputStream().read(bufferFichierEntree, 0, size)) != -1)
                     {
                         bos.write(bufferFichierEntree, 0, len);
                     }
InputStream is = new ByteArrayInputStream(bufferFichierEntree);
}
java.lang.OutOfMemoryErrorを返します:Javaヒープスペースと理由がわかりませんか?唯一の違いは、最初のケースでは、2番目のケースとは異なる関数を使用することです。