Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中的NegativeArraySizeException_Android - Fatal编程技术网

Android中的NegativeArraySizeException

Android中的NegativeArraySizeException,android,Android,我试图运行此代码,但出现错误。谁能告诉我为什么?调试器显示以下内容 线程[main](挂起(异常NegativeArraySizeException)) ViewRoot.handleMessage(消息)行:1704 ViewRoot(处理程序)。dispatchMessage(消息)行:99 Looper.loop()行:123 ActivityThread.main(字符串[])行:4203 invokenactive(Object,Object[],Class,Class[],Class

我试图运行此代码,但出现错误。谁能告诉我为什么?调试器显示以下内容

线程[main](挂起(异常NegativeArraySizeException)) ViewRoot.handleMessage(消息)行:1704 ViewRoot(处理程序)。dispatchMessage(消息)行:99 Looper.loop()行:123 ActivityThread.main(字符串[])行:4203 invokenactive(Object,Object[],Class,Class[],Class,int,boolean)行:不可用[本机方法] 调用(对象,对象…)行:521 ZygoteInit$MethodAndArgsCaller.run()行:791 颧骨单位。主(字符串[])行:549 NativeStart.main(字符串[])行:不可用[本机方法]

  public void convertAudio () throws IOException {
   Log.d("FILE", "Converting Audio");
   java.io.File fileExist = new java.io.File("/sdcard/" , "test1.3gp");
   java.io.File fileNew = new java.io.File("/sdcard/" , "test2.3gp");
   if (fileNew.exists()) {
    FileInputStream fExist = new FileInputStream(fileExist); 
       FileInputStream fNew = new FileInputStream(fileNew);

       long lengthExist = fileExist.length();
       if (lengthExist > Integer.MAX_VALUE) {
             // File is too large
       }
       byte[] bytesExist = new byte[(int)lengthExist];

       int offset = 0;
       int numRead = 0;
       try {
        while (offset < bytesExist.length && (numRead=fExist.read(bytesExist, offset, bytesExist.length-offset)) >= 0) {
             offset += numRead;
        }
       } finally {


       }

       // Ensure all the bytes have been read in
       if (offset < bytesExist.length) {
             throw new IOException("Could not completely read file "+fileExist.getName());
       }


       byte[] cleanExist = convert3gpDataToAmr(bytesExist);

       long lengthNew = fileNew.length();
       if (lengthNew > Integer.MAX_VALUE) {
             // File is too large
       }
       byte[] bytesNew = new byte[(int)lengthNew];

       int offsetNew = 0;
       int numReadNew = 0;
       try {
        while (offset < bytesNew.length && (numRead=fNew.read(bytesNew, offsetNew, bytesNew.length-offsetNew)) >= 0) {
         offsetNew += numReadNew;
        }
        } finally {


        }

       // Ensure all the bytes have been read in
       if (offset < bytesNew.length) {
             throw new IOException("Could not completely read file "+fileExist.getName());
       }


       byte[] cleanNew = convert3gpDataToAmr(bytesNew);       

   }


  }

我会检查
fullAmrDataLength
是否为负值,因为

byte[] amrData = new byte[fullAmrDataLength];

会导致
消极的raysizeexception

@viperdududuk:这方面运气好吗?
byte[] amrData = new byte[fullAmrDataLength];