java中的video隐写术

我正在为我的项目实施video隐写术。 我从这里看到了算法。 我已经尝试并测试了代码,嵌入部分工作正常。 但我遇到了readByte的问题,这是VideoSteganography类中的最后一个方法。 该方法给出了ArrayIndexOutOfBoundsException 。 以下是方法。

我将参数传递给

  String fname = jTextField3.getText(); File fil = new File(fname); String password = "123456"; SteganoInformation cls = new SteganoInformation(fil); VideoSteganography.retrieveFile(cls, password, true); 

而方法是

 public static boolean retrieveFile(SteganoInformation info, String password, boolean overwrite) { File dataFile= null; features= info.getFeatures(); try { masterFile= info.getFile(); byteArrayIn= new byte[(int) masterFile.length()]; DataInputStream in= new DataInputStream(new FileInputStream(masterFile)); in.read(byteArrayIn, 0, (int)masterFile.length()); in.close(); messageSize= info.getDataLength(); byte[] fileArray= new byte[messageSize]; inputOutputMarker= info.getInputMarker(); readBytes(fileArray); ....... } 

注意上面的方法readBytes,它抛出exception并写成如下

 private static void readBytes(byte[] bytes) { int size= bytes.length; for(int i=0; i<size ; i++) { bytes[i]= byteArrayIn[inputOutputMarker]; inputOutputMarker++; } } 

这里的问题是“byteArrayIn [inputOutputMarker]”,重新检查inputOutputMarker的值以及它可能具有的值的范围。

@Mazen Wadi,谢谢你的回复。 但我想是什么触发了这个exception,并希望分享一些人会遇到同样的问题。 从两个类“VideoSteganography类”和“SteganoInformation类”中,两个类中的方法retrieveBytes()有两个循环。 将循环更改为下面的循环,并确保两个类中的循环大小计数。 注意:从两个类的retrieveBytes方法更改j = 6,您的问题就解决了。

 private static void retrieveBytes(byte[] bytes) { int size= bytes.length; for(int i=0; i< size; i++) { byte1= 0; for(int j=6; j>=0; j-=2) { byte2= byteArrayIn[inputOutputMarker]; inputOutputMarker++; byte2&= 0x03; byte2<<= j; byte1|= byte2; } bytes[i]= byte1; } }