Example usage for java.util ArrayDeque toArray

List of usage examples for java.util ArrayDeque toArray

Introduction

In this page you can find the example usage for java.util ArrayDeque toArray.

Prototype

public Object[] toArray() 

Source Link

Document

Returns an array containing all of the elements in this deque in proper sequence (from first to last element).

Usage

From source file:Main.java

public static void main(String[] args) {

    ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8);

    deque.add(3);/*from   w w w .  j  av  a  2s. c  o m*/
    deque.add(1);
    deque.add(25);
    deque.add(18);

    System.out.println(deque);

    // printing the array length of elements added above
    Object[] ob = deque.toArray();
    System.out.println("\n Array Size : " + ob.length);
}

From source file:com.sonymobile.android.media.internal.VUParser.java

private boolean parseMtdt(BoxHeader header) {
    boolean parseOK = true;
    // if mCurrentBoxSequence contains trak, then add metadata to current
    // track//from w  w w  .  j ava2  s  . c  o  m
    // else metadata is for file
    // we're currently not interested in anything on track level
    try {
        int numberOfUnits = mDataSource.readShort();
        mHmmpTitles = new ArrayList<String>(1);
        ArrayDeque<String> titleLanguages = new ArrayDeque<String>(1);
        ArrayDeque<String> iconLanguages = new ArrayDeque<String>(1);
        for (int i = 0; i < numberOfUnits; i++) {
            short dataUnitSize = mDataSource.readShort();
            int dataTypeID = mDataSource.readInt();
            short language = mDataSource.readShort();
            char l1 = Character.toChars(((language >> 10) & 0x1F) + 96)[0];
            char l2 = Character.toChars(((language >> 5) & 0x1F) + 96)[0];
            char l3 = Character.toChars(((language) & 0x1F) + 96)[0];
            String languageString = "" + l1 + l2 + l3;
            short encodingType = mDataSource.readShort();
            if (encodingType == 0x01) {
                byte[] metadata = new byte[dataUnitSize - 10];
                mDataSource.read(metadata);
                String metadataString = new String(metadata, "UTF-16BE").trim();
                if ((dataTypeID & 0xFFFF) == 0x01) {
                    mHmmpTitles.add(metadataString);
                    titleLanguages.add(languageString);
                }
            } else if (encodingType == 0x101) {
                if (dataTypeID == 0xA04) {
                    if (mIconList == null) {
                        mIconList = new ArrayList<IconInfo>();
                    }
                    mDataSource.skipBytes(4); // selectionFlags
                    mDataSource.skipBytes(4); // reserved
                    int artworkCount = mDataSource.readInt();
                    for (int j = 0; j < artworkCount; j++) {
                        IconInfo iconInfo = new IconInfo();
                        iconInfo.mtsmId = mDataSource.readInt();
                        iconInfo.mdstIndex = mDataSource.readInt();
                        iconInfo.languageIndex = iconLanguages.size();
                        mDataSource.skipBytes(4);
                        mIconList.add(iconInfo);
                    }
                    iconLanguages.add(languageString);
                }
            }
        }
        addMetaDataValue(KEY_HMMP_TITLE_LANGUAGES, titleLanguages.toArray());
        addMetaDataValue(KEY_HMMP_ICON_LANGUAGES, iconLanguages.toArray());
    } catch (EOFException e) {
        if (LOGS_ENABLED)
            Log.e(TAG, "Exception while reading from 'MTDT' box", e);
        return false;
    } catch (IOException e) {
        if (LOGS_ENABLED)
            Log.e(TAG, "Exception while reading from 'MTDT' box", e);
        return false;
    }
    return parseOK;
}