本文整理匯總了Java中it.unimi.dsi.fastutil.bytes.ByteBigArrays.newBigArray方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBigArrays.newBigArray方法的具體用法?Java ByteBigArrays.newBigArray怎麽用?Java ByteBigArrays.newBigArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類it.unimi.dsi.fastutil.bytes.ByteBigArrays
的用法示例。
在下文中一共展示了ByteBigArrays.newBigArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBigBytes
import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入方法依賴的package包/類
public void testBigBytes( byte[][] a ) throws IOException {
final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
file.deleteOnExit();
final long length = ByteBigArrays.length( a );
final byte[][] aShifted = ByteBigArrays.newBigArray( length + 1 );
ByteBigArrays.copy( a, 0, aShifted, 1, length );
for( int i = 0; i < 4; i++ ) {
file.delete();
switch(i) {
case 0: TextIO.storeBytes( a, file ); break;
case 1: TextIO.storeBytes( a, new PrintStream( file ) ); break;
case 2: TextIO.storeBytes( aShifted, 1, length, file ); break;
case 3: TextIO.storeBytes( aShifted, 1, length, new PrintStream( file ) ); break;
}
byte[][] b = ByteBigArrays.newBigArray( length );
assertEquals( length, TextIO.loadBytes( file, b ) );
assertArrayEquals( a, b );
assertEquals( length, TextIO.loadBytes( file, b, 0, length ) );
assertArrayEquals( a, b );
assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), b ) );
assertArrayEquals( a, b );
assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), b, 0, length ) );
assertArrayEquals( a, b );
byte[][] c = ByteBigArrays.newBigArray( length + 1 );
assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), c ) );
assertEquals( 0, ByteBigArrays.get( c, length ) );
ByteBigArrays.copy( c, 0, b, 0, b.length );
assertArrayEquals( a, b );
assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), c, 1, length ) );
assertEquals( 0, ByteBigArrays.get( c, 0 ) );
ByteBigArrays.copy( c, 1, b, 0, b.length );
assertArrayEquals( a, b );
}
}
示例2: testBigBytes
import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入方法依賴的package包/類
public void testBigBytes( byte[][] a ) throws IOException {
final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
file.deleteOnExit();
final long length = ByteBigArrays.length( a );
final byte[][] aShifted = ByteBigArrays.newBigArray( length + 1 );
ByteBigArrays.copy( a, 0, aShifted, 1, length );
for( int i = 0; i < 6; i++ ) {
file.delete();
switch(i) {
case 0: BinIO.storeBytes( a, file ); break;
case 1: BinIO.storeBytes( a, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
case 2: BinIO.storeBytes( a, new FileOutputStream( file ) ); break;
case 3: BinIO.storeBytes( aShifted, 1, length, file ); break;
case 4: BinIO.storeBytes( aShifted, 1, length, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
case 5: BinIO.storeBytes( aShifted, 1, length, new FileOutputStream( file ) ); break;
}
assertArrayEquals( a, BinIO.loadBytesBig( file ) );
byte[][] b = ByteBigArrays.newBigArray( length );
assertEquals( length, BinIO.loadBytes( file, b ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( file, b, 0, length ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b ) );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b, 0, length ) );
assertArrayEquals( a, b );
byte[][] c = ByteBigArrays.newBigArray( length + 1 );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c ) );
assertEquals( 0, ByteBigArrays.get( c, length ) );
ByteBigArrays.copy( c, 0, b, 0, b.length );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c, 1, length ) );
assertEquals( 0, ByteBigArrays.get( c, 0 ) );
ByteBigArrays.copy( c, 1, b, 0, b.length );
assertArrayEquals( a, b );
ByteBigArrays.set( c, length, (byte)0 );
assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c ) );
assertEquals( 0, ByteBigArrays.get( c, length ) );
ByteBigArrays.copy( c, 0, b, 0, b.length );
assertArrayEquals( a, b );
assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c, 1, length ) );
assertEquals( 0, ByteBigArrays.get( c, 0 ) );
ByteBigArrays.copy( c, 1, b, 0, b.length );
assertArrayEquals( a, b );
}
}