java创建byte数组_java.创建一个byte数组,long length = file.length(); byte[] bytes =

博客主要讲述了Java创建byte数组时遇到的问题,使用`long length = file.length(); byte[] bytes = new byte[(int)length];`代码创建数组,结果出现`java.lang.OutOfMemoryError:Java heap space`错误,length大小为150994943,并询问解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导航:网站首页 >

java.创建一个byte数组,long length = file.length(); byte[] bytes =

时间:2017-12-17

java.创建一个byte数组,long length = file.length(); byte[] bytes = new byte[(int)length]; 结果导致

问题错误为:java.lang.OutOfMemoryError:Java heap space

\x05at com.hitrust.FCBCNB.service.impl.MONServiceImpl.getBytesFromFile(MONServiceImpl.java:76)

\x05at com.hitrust.FCBCNB.service.impl.MONServiceImpl.spliteBytes(MONServiceImpl.java:97)

\x05at com.hitrust.FCBCNB.service.impl.MONServiceImpl.getFileLine(MONServiceImpl.java:59)

\x05at com.hitrust.FCBCNB.service.impl.MONServiceImpl.upload(MONServiceImpl.java:45)

\x05at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

\x05at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

\x05at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

\x05at java.lang.reflect.Method.invoke(Method.java:597)

\x05at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)

\x05at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)

\x05at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)

\x05at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

\x05at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)

\x05at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)

\x05at $Proxy6.upload(Unknown Source)

\x05at com.hitrust.FCBCNB.test.MonTest.testA(MonTest.java:30)

\x05at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

\x05at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

\x05at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

\x05at java.lang.reflect.Method.invoke(Method.java:597)

\x05at junit.framework.TestCase.runTest(TestCase.java:154)

\x05at junit.framework.TestCase.runBare(TestCase.java:127)

\x05at junit.framework.TestResult$1.protect(TestResult.java:106)

\x05at junit.framework.TestResult.runProtected(TestResult.java:124)

\x05at junit.framework.TestResult.run(TestResult.java:109)

\x05at junit.framework.TestCase.run(TestCase.java:118)

\x05at junit.framework.TestSuite.runTest(TestSuite.java:208)

\x05at junit.framework.TestSuite.run(TestSuite.java:203)

\x05at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)

\x05at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

\x05at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)

\x05at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)

请问该如何解决,这里的length大小为150994943.

相关问题:

匿名网友:

好恐怖的长度

大家还关注:

问题推荐

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值