Example usage for java.nio ByteBuffer order

List of usage examples for java.nio ByteBuffer order

Introduction

In this page you can find the example usage for java.nio ByteBuffer order.

Prototype

Endianness order

To view the source code for java.nio ByteBuffer order.

Click Source Link

Document

The byte order of this buffer, default is BIG_ENDIAN .

Usage

From source file:org.bimserver.geometry.StreamingGeometryGenerator.java

void setTransformationMatrix(VirtualObject geometryInfo, double[] transformationMatrix)
        throws BimserverDatabaseException {
    ByteBuffer byteBuffer = ByteBuffer.allocate(16 * 8);
    byteBuffer.order(ByteOrder.nativeOrder());
    DoubleBuffer asDoubleBuffer = byteBuffer.asDoubleBuffer();
    for (double d : transformationMatrix) {
        asDoubleBuffer.put(d);//from  w w w  .  ja v a 2 s  .  co m
    }
    geometryInfo.setAttribute(GeometryPackage.eINSTANCE.getGeometryInfo_Transformation(), byteBuffer.array());
}

From source file:org.bimserver.geometry.GeometryRunner.java

private ByteBuffer quantizeNormals(FloatBuffer normals) {
    ByteBuffer quantizedNormals = ByteBuffer.wrap(new byte[normals.capacity()]);
    quantizedNormals.order(ByteOrder.LITTLE_ENDIAN);
    for (int i = 0; i < normals.capacity(); i++) {
        float normal = normals.get(i);
        quantizedNormals.put((byte) (normal * 127));
    }//  ww  w  .  j a  va 2  s .c om
    return quantizedNormals;
}

From source file:ffx.xray.parsers.MTZFilter.java

/**
 * {@inheritDoc}// w w w. j  a v a  2  s.co m
 */
@Override
public boolean readFile(File mtzFile, ReflectionList reflectionList, DiffractionRefinementData refinementData,
        CompositeConfiguration properties) {
    int nRead, nIgnore, nRes, nFriedel, nCut;
    ByteOrder byteOrder = ByteOrder.nativeOrder();
    FileInputStream fileInputStream;
    DataInputStream dataInputStream;
    boolean transpose = false;

    StringBuilder sb = new StringBuilder();
    try {
        fileInputStream = new FileInputStream(mtzFile);
        dataInputStream = new DataInputStream(fileInputStream);

        byte headerOffset[] = new byte[4];
        byte bytes[] = new byte[80];
        int offset = 0;

        // Eat "MTZ" title.
        dataInputStream.read(bytes, offset, 4);
        String mtzstr = null;

        // Header offset.
        dataInputStream.read(headerOffset, offset, 4);

        // Machine stamp.
        dataInputStream.read(bytes, offset, 4);
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        int stamp = byteBuffer.order(ByteOrder.BIG_ENDIAN).getInt();
        String stampString = Integer.toHexString(stamp);
        switch (stampString.charAt(0)) {
        case '1':
        case '3':
            if (byteOrder.equals(ByteOrder.LITTLE_ENDIAN)) {
                byteOrder = ByteOrder.BIG_ENDIAN;
            }
            break;
        case '4':
            if (byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
                byteOrder = ByteOrder.LITTLE_ENDIAN;
            }
            break;
        }

        byteBuffer = ByteBuffer.wrap(headerOffset);
        int headerOffsetI = byteBuffer.order(byteOrder).getInt();

        // skip to header and parse
        dataInputStream.skipBytes((headerOffsetI - 4) * 4);

        for (Boolean parsing = true; parsing; dataInputStream.read(bytes, offset, 80)) {
            mtzstr = new String(bytes);
            parsing = parseHeader(mtzstr);
        }

        // column identifiers
        foString = sigFoString = rFreeString = null;
        if (properties != null) {
            foString = properties.getString("fostring", null);
            sigFoString = properties.getString("sigfostring", null);
            rFreeString = properties.getString("rfreestring", null);
        }
        h = k = l = fo = sigFo = rFree = -1;
        fPlus = sigFPlus = fMinus = sigFMinus = rFreePlus = rFreeMinus = -1;
        boolean print = true;
        parseColumns(print);

        if (h < 0 || k < 0 || l < 0) {
            String message = "Fatal error in MTZ file - no H K L indexes?\n";
            logger.log(Level.SEVERE, message);
            return false;
        }

        // Reopen to start at beginning.
        fileInputStream = new FileInputStream(mtzFile);
        dataInputStream = new DataInputStream(fileInputStream);

        // Skip initial header.
        dataInputStream.skipBytes(80);

        // Check if HKLs need to be transposed or not.
        float data[] = new float[nColumns];
        HKL mate = new HKL();
        int nPosIgnore = 0;
        int nTransIgnore = 0;
        int nZero = 0;
        int none = 0;
        for (int i = 0; i < nReflections; i++) {
            for (int j = 0; j < nColumns; j++) {
                dataInputStream.read(bytes, offset, 4);
                byteBuffer = ByteBuffer.wrap(bytes);
                data[j] = byteBuffer.order(byteOrder).getFloat();
            }
            int ih = (int) data[h];
            int ik = (int) data[k];
            int il = (int) data[l];
            boolean friedel = reflectionList.findSymHKL(ih, ik, il, mate, false);
            HKL hklpos = reflectionList.getHKL(mate);
            if (hklpos == null) {
                nPosIgnore++;
            }

            friedel = reflectionList.findSymHKL(ih, ik, il, mate, true);
            HKL hkltrans = reflectionList.getHKL(mate);
            if (hkltrans == null) {
                nTransIgnore++;
            }
            if (rFree > 0) {
                if (((int) data[rFree]) == 0) {
                    nZero++;
                } else if (((int) data[rFree]) == 1) {
                    none++;
                }
            }
            if (rFreePlus > 0) {
                if (((int) data[rFreePlus]) == 0) {
                    nZero++;
                } else if (((int) data[rFreePlus]) == 1) {
                    none++;
                }
            }
            if (rFreeMinus > 0) {
                if (((int) data[rFreeMinus]) == 0) {
                    nZero++;
                } else if (((int) data[rFreeMinus]) == 1) {
                    none++;
                }
            }
        }
        if (nPosIgnore > nTransIgnore) {
            transpose = true;
        }

        if (none > (nZero * 2) && refinementData.rfreeflag < 0) {
            refinementData.setFreeRFlag(0);
            sb.append(format(" Setting R free flag to %d based on MTZ file data.\n", refinementData.rfreeflag));
        } else if (nZero > (none * 2) && refinementData.rfreeflag < 0) {
            refinementData.setFreeRFlag(1);
            sb.append(format(" Setting R free flag to %d based on MTZ file data.\n", refinementData.rfreeflag));
        } else if (refinementData.rfreeflag < 0) {
            refinementData.setFreeRFlag(0);
            sb.append(format(" Setting R free flag to MTZ default: %d\n", refinementData.rfreeflag));
        }

        // reopen to start at beginning
        fileInputStream = new FileInputStream(mtzFile);
        dataInputStream = new DataInputStream(fileInputStream);

        // skip initial header
        dataInputStream.skipBytes(80);

        // read in data
        double anofSigF[][] = new double[refinementData.n][4];
        for (int i = 0; i < refinementData.n; i++) {
            anofSigF[i][0] = anofSigF[i][1] = anofSigF[i][2] = anofSigF[i][3] = Double.NaN;
        }
        nRead = nIgnore = nRes = nFriedel = nCut = 0;
        for (int i = 0; i < nReflections; i++) {
            for (int j = 0; j < nColumns; j++) {
                dataInputStream.read(bytes, offset, 4);
                byteBuffer = ByteBuffer.wrap(bytes);
                data[j] = byteBuffer.order(byteOrder).getFloat();
            }
            int ih = (int) data[h];
            int ik = (int) data[k];
            int il = (int) data[l];
            boolean friedel = reflectionList.findSymHKL(ih, ik, il, mate, transpose);
            HKL hkl = reflectionList.getHKL(mate);
            if (hkl != null) {
                if (fo > 0 && sigFo > 0) {
                    if (refinementData.fsigfcutoff > 0.0) {
                        if ((data[fo] / data[sigFo]) < refinementData.fsigfcutoff) {
                            nCut++;
                            continue;
                        }
                    }
                    if (friedel) {
                        anofSigF[hkl.index()][2] = data[fo];
                        anofSigF[hkl.index()][3] = data[sigFo];
                        nFriedel++;
                    } else {
                        anofSigF[hkl.index()][0] = data[fo];
                        anofSigF[hkl.index()][1] = data[sigFo];
                    }
                } else {
                    if (fPlus > 0 && sigFPlus > 0) {
                        if (refinementData.fsigfcutoff > 0.0) {
                            if ((data[fPlus] / data[sigFPlus]) < refinementData.fsigfcutoff) {
                                nCut++;
                                continue;
                            }
                        }
                        anofSigF[hkl.index()][0] = data[fPlus];
                        anofSigF[hkl.index()][1] = data[sigFPlus];
                    }
                    if (fMinus > 0 && sigFMinus > 0) {
                        if (refinementData.fsigfcutoff > 0.0) {
                            if ((data[fMinus] / data[sigFMinus]) < refinementData.fsigfcutoff) {
                                nCut++;
                                continue;
                            }
                        }
                        anofSigF[hkl.index()][2] = data[fMinus];
                        anofSigF[hkl.index()][3] = data[sigFMinus];
                    }
                }
                if (rFree > 0) {
                    refinementData.setFreeR(hkl.index(), (int) data[rFree]);
                } else {
                    if (rFreePlus > 0 && rFreeMinus > 0) {
                        // not sure what the correct thing to do here is?
                        refinementData.setFreeR(hkl.index(), (int) data[rFreePlus]);
                    } else if (rFreePlus > 0) {
                        refinementData.setFreeR(hkl.index(), (int) data[rFreePlus]);
                    } else if (rFreeMinus > 0) {
                        refinementData.setFreeR(hkl.index(), (int) data[rFreeMinus]);
                    }
                }
                nRead++;
            } else {
                HKL tmp = new HKL(ih, ik, il);
                if (!reflectionList.resolution
                        .inInverseResSqRange(Crystal.invressq(reflectionList.crystal, tmp))) {
                    nRes++;
                } else {
                    nIgnore++;
                }
            }
        }

        // Set up fsigf from F+ and F-.
        refinementData.generate_fsigf_from_anofsigf(anofSigF);

        // Log results.
        if (logger.isLoggable(Level.INFO)) {
            sb.append(format(" MTZ file type (machine stamp): %s\n", stampString));
            sb.append(format(" HKL data is %s\n", transpose ? "transposed" : "not transposed"));
            sb.append(format(" HKL read in:                             %d\n", nRead));
            sb.append(format(" HKL read as friedel mates:               %d\n", nFriedel));
            sb.append(format(" HKL NOT read in (too high resolution):   %d\n", nRes));
            sb.append(format(" HKL NOT read in (not in internal list?): %d\n", nIgnore));
            sb.append(format(" HKL NOT read in (F/sigF cutoff):         %d\n", nCut));
            sb.append(format(" HKL in internal list:                    %d\n", reflectionList.hkllist.size()));
            logger.info(sb.toString());
        }
        if (rFree < 0 && rFreePlus < 0 && rFreeMinus < 0) {
            refinementData.generateRFree();
        }
    } catch (EOFException e) {
        String message = " MTZ end of file reached.";
        logger.log(Level.WARNING, message, e);
        return false;
    } catch (IOException e) {
        String message = " MTZ IO Exception.";
        logger.log(Level.WARNING, message, e);
        return false;
    }

    return true;
}

From source file:org.bimserver.geometry.GeometryRunner.java

private ByteBuffer quantizeVertices(float[] vertices, float[] quantizationMatrix, float multiplierToMm) {
    ByteBuffer quantizedBuffer = ByteBuffer.wrap(new byte[vertices.length * 2]);
    quantizedBuffer.order(ByteOrder.LITTLE_ENDIAN);

    float[] vertex = new float[4];
    float[] result = new float[4];
    vertex[3] = 1;/*  w w w  . j  a  va 2 s .co m*/
    int nrVertices = vertices.length;
    for (int i = 0; i < nrVertices; i += 3) {
        vertex[0] = vertices[i];
        vertex[1] = vertices[i + 1];
        vertex[2] = vertices[i + 2];

        if (multiplierToMm != 1f) {
            vertex[0] = vertex[0] * multiplierToMm;
            vertex[1] = vertex[1] * multiplierToMm;
            vertex[2] = vertex[2] * multiplierToMm;
        }

        Matrix.multiplyMV(result, 0, quantizationMatrix, 0, vertex, 0);

        quantizedBuffer.putShort((short) result[0]);
        quantizedBuffer.putShort((short) result[1]);
        quantizedBuffer.putShort((short) result[2]);
    }

    return quantizedBuffer;
}

From source file:org.bimserver.geometry.StreamingGeometryGenerator.java

private ByteBuffer quantizeVertices(DoubleBuffer vertices, double[] quantizationMatrix, double multiplierToMm) {
    ByteBuffer quantizedBuffer = ByteBuffer.wrap(new byte[vertices.capacity() * 2]);
    quantizedBuffer.order(ByteOrder.LITTLE_ENDIAN);

    double[] vertex = new double[4];
    double[] result = new double[4];
    vertex[3] = 1;//from ww  w  .j ava 2  s.co m
    int nrVertices = vertices.capacity();
    for (int i = 0; i < nrVertices; i += 3) {
        vertex[0] = vertices.get(i);
        vertex[1] = vertices.get(i + 1);
        vertex[2] = vertices.get(i + 2);

        if (multiplierToMm != 1f) {
            vertex[0] = vertex[0] * multiplierToMm;
            vertex[1] = vertex[1] * multiplierToMm;
            vertex[2] = vertex[2] * multiplierToMm;
        }

        Matrix.multiplyMV(result, 0, quantizationMatrix, 0, vertex, 0);

        quantizedBuffer.putShort((short) result[0]);
        quantizedBuffer.putShort((short) result[1]);
        quantizedBuffer.putShort((short) result[2]);
    }

    return quantizedBuffer;
}

From source file:org.openteufel.file.mpq.MPQFileSector.java

protected MPQFileSector(boolean compressed, boolean imploded, int sizeUncompressed, ByteBuffer src,
        Long encryptionSeed) throws DataFormatException, IOException {
    this.encryptionSeed = encryptionSeed;
    this.sizeUncompressed = sizeUncompressed;

    if (sizeUncompressed == src.remaining()) {
        compression = Compression.Uncompressed;
    } else if (imploded) {
        compression = Compression.Imploded;
    } else if (compressed) {
        byte compressionByte = src.get();
        if (compressionByte == COMPRESSION_ZLIB) {
            compression = Compression.ZLib;
        } else if (compressionByte == COMPRESSION_BZIP2) {
            compression = Compression.BZip2;
        } else {//from  w w w. ja  va  2 s  .c  om
            // Unkown compression
            compression = Compression.Uncompressed;
            /*
             * Count the compression byte to the data. Sectors are not
             * necessarily compressed, if the according flag is set. If the
             * compression byte is unknown, compressed sector are treated as
             * uncompressed.
             */
            src.position(src.position() - 1);
        }
    } else {
        compression = Compression.Uncompressed;
    }
    dataRaw = src.slice();
    dataRaw.order(src.order());
}

From source file:ar.com.qbe.siniestros.model.utils.MimeMagic.MagicMatcher.java

/**
 * internal test switch/*  ww w .  ja v  a2s  .  com*/
 * 
 * @param data DOCUMENT ME!
 * @return DOCUMENT ME!
 */
private boolean testInternal(byte[] data) {
    log.debug("testInternal(byte[])");

    if (data.length == 0) {
        return false;
    }

    String type = match.getType();
    String test = new String(match.getTest().array());
    String mimeType = match.getMimeType();
    String description = match.getDescription();

    ByteBuffer buffer = ByteBuffer.allocate(data.length);

    if ((type != null) && (test != null) && (test.length() > 0)) {
        if (type.equals("string")) {
            buffer = buffer.put(data);

            return testString(buffer);
        } else if (type.equals("byte")) {
            buffer = buffer.put(data);

            return testByte(buffer);
        } else if (type.equals("short")) {
            buffer = buffer.put(data);

            return testShort(buffer);
        } else if (type.equals("leshort")) {
            buffer = buffer.put(data);
            buffer.order(ByteOrder.LITTLE_ENDIAN);

            return testShort(buffer);
        } else if (type.equals("beshort")) {
            buffer = buffer.put(data);
            buffer.order(ByteOrder.BIG_ENDIAN);

            return testShort(buffer);
        } else if (type.equals("long")) {
            buffer = buffer.put(data);

            return testLong(buffer);
        } else if (type.equals("lelong")) {
            buffer = buffer.put(data);
            buffer.order(ByteOrder.LITTLE_ENDIAN);

            return testLong(buffer);
        } else if (type.equals("belong")) {
            buffer = buffer.put(data);
            buffer.order(ByteOrder.BIG_ENDIAN);

            return testLong(buffer);
        } else if (type.equals("regex")) {
            return testRegex(new String(data));
        } else if (type.equals("detector")) {
            buffer = buffer.put(data);

            return testDetector(buffer);

            //         } else if (type.equals("date")) {
            //            return testDate(data, BIG_ENDIAN);
            //         } else if (type.equals("ledate")) {
            //            return testDate(data, LITTLE_ENDIAN);
            //         } else if (type.equals("bedate")) {
            //            return testDate(data, BIG_ENDIAN);
        } else {
            log.error("testInternal(byte[]): invalid test type '" + type + "'");
        }
    } else {
        log.error("testInternal(byte[]): type or test is empty for '" + mimeType + " - " + description + "'");
    }

    return false;
}

From source file:edu.vu.isis.ammo.dash.provider.IncidentSyncAdaptor.java

public ArrayList<File> mediaSerialize(Cursor cursor) {
    logger.debug("::mediaSerialize");
    ArrayList<File> paths = new ArrayList<File>();
    if (1 > cursor.getCount())
        return paths;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream eos = new DataOutputStream(baos);

    for (boolean more = cursor.moveToFirst(); more; more = cursor.moveToNext()) {
        MediaWrapper iw = new MediaWrapper();
        iw.setEventId(cursor.getString(cursor.getColumnIndex(MediaTableSchemaBase.EVENT_ID)));
        iw.setDataType(cursor.getString(cursor.getColumnIndex(MediaTableSchemaBase.DATA_TYPE)));
        iw.setData(cursor.getString(cursor.getColumnIndex(MediaTableSchemaBase.DATA)));
        iw.setCreatedDate(cursor.getLong(cursor.getColumnIndex(MediaTableSchemaBase.CREATED_DATE)));
        iw.setModifiedDate(cursor.getLong(cursor.getColumnIndex(MediaTableSchemaBase.MODIFIED_DATE)));
        iw.set_ReceivedDate(cursor.getLong(cursor.getColumnIndex(MediaTableSchemaBase._RECEIVED_DATE)));
        iw.set_Disposition(cursor.getInt(cursor.getColumnIndex(MediaTableSchemaBase._DISPOSITION)));

        Gson gson = new Gson();

        try {/*  w  ww.  j  a va  2s. co  m*/
            eos.writeBytes(gson.toJson(iw));
            eos.writeByte(0);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        // not a reference field name :event id eventId event_id\n 
        try {
            String fileName = iw.getData();
            File dataFile = new File(fileName);
            int dataSize = (int) dataFile.length();
            byte[] buffData = new byte[dataSize];
            FileInputStream fileStream = new FileInputStream(dataFile);
            int ret = 0;
            for (int position = 0; (ret > -1 && dataSize > position); position += ret) {
                ret = fileStream.read(buffData, position, dataSize - position);
            }
            fileStream.close();

            eos.writeBytes("data");
            eos.writeByte(0);

            ByteBuffer dataSizeBuf = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE);
            dataSizeBuf.order(ByteOrder.LITTLE_ENDIAN);
            dataSizeBuf.putInt(dataSize);

            // write the media back out
            eos.write(dataSizeBuf.array());
            eos.write(buffData);
            eos.write(dataSizeBuf.array());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // not a reference field name :created date createdDate created_date\n 
        // not a reference field name :modified date modifiedDate modified_date\n 
        // MediaTableSchemaBase._DISPOSITION;

        //           try {
        // TODO write to content provider using openFile
        // if (!applCacheMediaDir.exists() ) applCacheMediaDir.mkdirs();

        // File outfile = new File(applCacheMediaDir, Integer.toHexString((int) System.currentTimeMillis())); 
        //              BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream(outfile), 8192);
        //              bufferedOutput.write(baos.toByteArray());
        //              bufferedOutput.flush();
        //              bufferedOutput.close();

        //           } catch (FileNotFoundException e) {
        //              e.printStackTrace();
        //           } catch (IOException e) {
        //              e.printStackTrace();
        //           }
    }
    return paths;
}

From source file:edu.vu.isis.ammo.dash.provider.IncidentSyncAdaptor.java

public ArrayList<File> categorySerialize(Cursor cursor) {
    logger.debug("::categorySerialize");
    ArrayList<File> paths = new ArrayList<File>();
    if (1 > cursor.getCount())
        return paths;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream eos = new DataOutputStream(baos);

    for (boolean more = cursor.moveToFirst(); more; more = cursor.moveToNext()) {
        CategoryWrapper iw = new CategoryWrapper();
        iw.setMainCategory(cursor.getString(cursor.getColumnIndex(CategoryTableSchemaBase.MAIN_CATEGORY)));
        iw.setSubCategory(cursor.getString(cursor.getColumnIndex(CategoryTableSchemaBase.SUB_CATEGORY)));
        iw.setTigrId(cursor.getString(cursor.getColumnIndex(CategoryTableSchemaBase.TIGR_ID)));
        iw.setIconType(cursor.getString(cursor.getColumnIndex(CategoryTableSchemaBase.ICON_TYPE)));
        iw.setIcon(cursor.getString(cursor.getColumnIndex(CategoryTableSchemaBase.ICON)));
        iw.set_ReceivedDate(cursor.getLong(cursor.getColumnIndex(CategoryTableSchemaBase._RECEIVED_DATE)));
        iw.set_Disposition(cursor.getInt(cursor.getColumnIndex(CategoryTableSchemaBase._DISPOSITION)));

        Gson gson = new Gson();

        try {/*from ww w. j a  v a  2s  . c  o  m*/
            eos.writeBytes(gson.toJson(iw));
            eos.writeByte(0);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        // not a reference field name :main category mainCategory main_category\n 
        // not a reference field name :sub category subCategory sub_category\n 
        // not a reference field name :tigr id tigrId tigr_id\n 
        try {
            String fileName = iw.getIcon();
            File dataFile = new File(fileName);
            int dataSize = (int) dataFile.length();
            byte[] buffData = new byte[dataSize];
            FileInputStream fileStream = new FileInputStream(dataFile);
            int ret = 0;
            for (int position = 0; (ret > -1 && dataSize > position); position += ret) {
                ret = fileStream.read(buffData, position, dataSize - position);
            }
            fileStream.close();

            eos.writeBytes("icon");
            eos.writeByte(0);

            ByteBuffer dataSizeBuf = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE);
            dataSizeBuf.order(ByteOrder.LITTLE_ENDIAN);
            dataSizeBuf.putInt(dataSize);

            // write the category back out
            eos.write(dataSizeBuf.array());
            eos.write(buffData);
            eos.write(dataSizeBuf.array());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // CategoryTableSchemaBase._DISPOSITION;

        //           try {
        //              if (!applCacheCategoryDir.exists() ) applCacheCategoryDir.mkdirs();
        //              
        //              File outfile = new File(applCacheCategoryDir, Integer.toHexString((int) System.currentTimeMillis())); 
        //              BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream(outfile), 8192);
        //              bufferedOutput.write(baos.toByteArray());
        //              bufferedOutput.flush();
        //              bufferedOutput.close();
        //           
        //              paths.add(outfile);
        //           } catch (FileNotFoundException e) {
        //              e.printStackTrace();
        //           } catch (IOException e) {
        //              e.printStackTrace();
        //           }
    }
    return paths;
}

From source file:com.googlecode.mp4parser.boxes.microsoft.XtraBox.java

@Override
public void _parseDetails(ByteBuffer content) {
    int boxSize = content.remaining();
    data = content.slice(); //Keep this in case we fail to parse
    successfulParse = false;/*from w  ww. j a  va 2 s.c  o  m*/
    try {
        tags.clear();
        while (content.remaining() > 0) {
            XtraTag tag = new XtraTag();
            tag.parse(content);
            tags.addElement(tag);
        }
        int calcSize = detailSize();
        if (boxSize != calcSize) {
            throw new RuntimeException("Improperly handled Xtra tag: Calculated sizes don't match ( " + boxSize
                    + "/" + calcSize + ")");
        }
        successfulParse = true;
    } catch (Exception e) {
        successfulParse = false;
        System.err.println("Malformed Xtra Tag detected: " + e.toString());
        e.printStackTrace();
        content.position(content.position() + content.remaining());
    } finally {
        content.order(ByteOrder.BIG_ENDIAN); //Just in case we bailed out mid-parse we don't want to leave the byte order in MS land
    }
}