Results 1 to 2 of 2
Thread: Combine Error
- 12-07-2011, 05:01 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
Combine Error
Hi, may i check is there any errors in my codes as I encountered an error called
"array out of bounds exception" Please advise me.Thank you
public InputStream combine(List<InputStream> slices, IdaInfo info) throws IDAException {
//Prepare output stream (the combined file)
ByteArrayOutputStream osCombinedFile = new ByteArrayOutputStream();
//IdaInfo class helps in managing parameters for the IDA algorithm (size, lengths, mod value etc)
//IdaInfo idainfo = new IdaInfo(5,3);
int m = info.getQuorum(); // if the input number of stream < m, algorithm cannot function
//Check if the List contains enough InputStream to perform the combine() operation.
if(slices.size() < m)
throw new IDAException("Error:combine(List<InputStream>):Ins ufficient slice available for combine operations");
//If the input list > m slices, we remove some, we only need m slices
List<InputStream> lstSlices = new ArrayList<InputStream>();
for (int i = 0; i < m; i++) {
lstSlices.add(slices.get(i));
}
//Retrieve the id of each slice. This is required to get the correct row in the key matrix
int[] sliceIds = null;
int[][] inverse = null;
int[] bytesFromSlices = null;
//use to track the number of bytes of output, this will remove adding padding bytes added previously
//int nOutputCount = 0;
long nOutputCount = info.getDataOffset();
int abyte;
//int nStreamSize = parseSegmentExtraData(lstSlices, sliceIds);
sliceIds = parseSegmentExtraData(lstSlices);
long nStreamSize = info.getDataSize();
//idainfo.setDataSize(nStreamSize);
//Prepare the inverse matrix
//inverse = generateInverse(sliceIds, m_nKeyMatrix);
inverse = generateInverse(sliceIds, info.getMatrix());
for (int i = 0; i < info.getSliceLength(); i++) {
bytesFromSlices = getNextByteFromSlices(lstSlices);
if(bytesFromSlices==null)
break;
for (int j = 0; j < m; j++) {
abyte = mac(bytesFromSlices, inverse[j]);
osCombinedFile.write(abyte);
nOutputCount++;
if(nOutputCount >= nStreamSize) {
//System.out.println("Output Count = " + nOutputCount + ", StreamSize = " + nStreamSize);
break;
}
}
}
//Return an InputStream for ease of use by calling function
return new ByteArrayInputStream(osCombinedFile.toByteArray()) ;
}
- 12-07-2011, 09:26 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Combine two S.O.P in one
By javauserjava in forum New To JavaReplies: 5Last Post: 04-05-2011, 06:27 AM -
How to combine Buttons and threads
By jnms in forum New To JavaReplies: 7Last Post: 02-24-2011, 09:06 PM -
can i combine this 2 code into one?
By reeveliew in forum New To JavaReplies: 3Last Post: 05-09-2010, 02:24 PM -
How can I do this? Combine variable.
By PeterFeng in forum New To JavaReplies: 5Last Post: 01-14-2009, 05:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks