Results 1 to 2 of 2

Thread: Combine Error

  1. #1
    cloud is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default 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++) {

    //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();

    //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);

    for (int j = 0; j < m; j++) {
    abyte = mac(bytesFromSlices, inverse[j]);
    if(nOutputCount >= nStreamSize) {
    //System.out.println("Output Count = " + nOutputCount + ", StreamSize = " + nStreamSize);

    //Return an InputStream for ease of use by calling function
    return new ByteArrayInputStream(osCombinedFile.toByteArray()) ;


  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Combine Error

    Post the full stack trace and error message for the exception, and show us where in your code it is occurring.

    Also use code tags when posting code.

Similar Threads

  1. Combine two S.O.P in one
    By javauserjava in forum New To Java
    Replies: 5
    Last Post: 04-05-2011, 07:27 AM
  2. How to combine Buttons and threads
    By jnms in forum New To Java
    Replies: 7
    Last Post: 02-24-2011, 10:06 PM
  3. can i combine this 2 code into one?
    By reeveliew in forum New To Java
    Replies: 3
    Last Post: 05-09-2010, 03:24 PM
  4. How can I do this? Combine variable.
    By PeterFeng in forum New To Java
    Replies: 5
    Last Post: 01-14-2009, 06:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts