src/main/java/com/allantaborda/ooogg/OggPage.java
public byte[][] addPackets(OggPackable... packets){
		if(packets.length == 1) return addPacket(packets[0]);
		ArrayList<byte[][]> tOverplus = new ArrayList<>(packets.length);
		for(OggPackable p : packets){
			byte[][] overplus = addPacket(p);
			if(overplus != null) tOverplus.add(overplus);
		}
		if(tOverplus.isEmpty()) return null;
		else if(tOverplus.size() == 1) return tOverplus.get(0);
		else{
			int sum = 0;
			for(byte[][] overplus : tOverplus) sum += overplus.length;
			byte[][] sOverplus = new byte[sum][];
			int pos = 0;
			for(byte[][] overplus : tOverplus){
				System.arraycopy(overplus, 0, sOverplus, pos, overplus.length);
				pos += overplus.length;
			}
			return sOverplus;
		}
	}
/**
	 * Adds one or more OGG packet to OGG page.
	 * @param packets The OGG packets.
	 * @return The overplus segments that don't fit in OGG page, or {@code null} if no overplus segments.
	 * @throws IllegalArgumentException If any OGG packet is not valid.
	 */
Adds one or more OGG packet to OGG page.
@param packets The OGG packets.
@return The overplus segments that don't fit in OGG page, or  null if no overplus segments.
@throws IllegalArgumentException If any OGG packet is not valid.
Adds one or more OGG packet to OGG page . @param packets The OGG packets . @return The overplus segments that don ' t fit in OGG page or null if no overplus segments . @throws IllegalArgumentException If any OGG packet is not valid .
public byte[][] addPackets(OggPackable... packets){
		if(packets.length == 1) return addPacket(packets[0]);
		ArrayList<byte[][]> tOverplus = new ArrayList<>(packets.length);
		for(OggPackable p : packets){
			byte[][] overplus = addPacket(p);
			if(overplus != null) tOverplus.add(overplus);
		}
		if(tOverplus.isEmpty()) return null;
		else if(tOverplus.size() == 1) return tOverplus.get(0);
		else{
			int sum = 0;
			for(byte[][] overplus : tOverplus) sum += overplus.length;
			byte[][] sOverplus = new byte[sum][];
			int pos = 0;
			for(byte[][] overplus : tOverplus){
				System.arraycopy(overplus, 0, sOverplus, pos, overplus.length);
				pos += overplus.length;
			}
			return sOverplus;
		}
	}
public byte [ ] [ ] addPackets ( OggPackable ... packets ) { if ( packets . length == 1 ) return addPacket ( packets [ 0 ] ) ; ArrayList < byte [ ] [ ] > tOverplus = new ArrayList < > ( packets . length ) ; for ( OggPackable p : packets ) { byte [ ] [ ] overplus = addPacket ( p ) ; if ( overplus != null ) tOverplus . add ( overplus ) ; } if ( tOverplus . isEmpty ( ) ) return null ; else if ( tOverplus . size ( ) == 1 ) return tOverplus . get ( 0 ) ; else { int sum = 0 ; for ( byte [ ] [ ] overplus : tOverplus ) sum += overplus . length ; byte [ ] [ ] sOverplus = new byte [ sum ] [ ] ; int pos = 0 ; for ( byte [ ] [ ] overplus : tOverplus ) { System . arraycopy ( overplus , 0 , sOverplus , pos , overplus . length ) ; pos += overplus . length ; } return sOverplus ; } }
Adds one or more OGG packet to OGG page.
Adds one or more OGG packet to OGG page .