/** * Writes the specified byte to this output stream. The general contract for write is that one byte is written * to the output stream. The byte to be written is the eight low-order bits of the argument b. * The 24 high-order bits of b are ignored. * @param bite * @throws IOException */ @Override public void write(final int bite) throws IOException { singleByteArray[0] = (byte)bite; write(singleByteArray); }
/** * Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) * is that it should have exactly the same effect as the call write(b, 0, b.length). * @param bytes the data */ @Override public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
/** * Writes the specified byte to this output stream. The general contract for write is that one byte is written * to the output stream. The byte to be written is the eight low-order bits of the argument b. * The 24 high-order bits of b are ignored. * @param bite * @throws IOException */ public void write(final int bite) throws IOException { singleByteArray[0] = (byte)bite; write(singleByteArray); }
/** * Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) * is that it should have exactly the same effect as the call write(b, 0, b.length). * @param bytes the data */ @Override public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
/** * Writes the specified byte to this output stream. The general contract for write is that one byte is written * to the output stream. The byte to be written is the eight low-order bits of the argument b. * The 24 high-order bits of b are ignored. * @param bite * @throws IOException */ @Override public void write(final int bite) throws IOException { singleByteArray[0] = (byte)bite; write(singleByteArray); }
/** * Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) * is that it should have exactly the same effect as the call write(b, 0, b.length). * @param bytes the data */ @Override public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
public void write(byte[] b, int off, int len) throws IOException { output.write(b, off, len); }
public void write(int b) throws IOException { output.write(b); }
public void write(byte[] b, int off, int len) throws IOException { output.write(b, off, len); }
public void write(int b) throws IOException { output.write(b); }
public void write(int b) throws IOException { output.write(b); }
public void write(byte[] b, int off, int len) throws IOException { output.write(b, off, len); }
private List<String> writeTempBlockCompressedFileForInflaterTest( final File tempFile ) throws IOException { final List<String> linesWritten = new ArrayList<>(); try ( final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(tempFile, 5) ) { String s = "Hi, Mom!\n"; bcos.write(s.getBytes()); //Call 1 linesWritten.add(s); s = "Hi, Dad!\n"; bcos.write(s.getBytes()); //Call 2 linesWritten.add(s); bcos.flush(); final StringBuilder sb = new StringBuilder(BlockCompressedStreamConstants.DEFAULT_UNCOMPRESSED_BLOCK_SIZE * 2); s = "1234567890123456789012345678901234567890123456789012345678901234567890\n"; while ( sb.length() <= BlockCompressedStreamConstants.DEFAULT_UNCOMPRESSED_BLOCK_SIZE ) { sb.append(s); linesWritten.add(s); } bcos.write(sb.toString().getBytes()); //Call 3 } return linesWritten; }
@Test(groups = "broken") public void testDevNull() throws Exception { final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream("/dev/null"); bcos.write("Hi, Mom!".getBytes()); bcos.close(); }
private static File getValidCompressedFile() throws IOException { final File tmpCompressedFile = File.createTempFile("test.", ".bgzf"); tmpCompressedFile.deleteOnExit(); final BlockCompressedOutputStream os = new BlockCompressedOutputStream(tmpCompressedFile); os.write("Hi, Mom!\n".getBytes()); os.close(); return tmpCompressedFile; }
private long populateMultiBlockCompressedFile(final File tempBlockCompressedFile) throws IOException { long sentinelLineOffset = -1; try (BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(tempBlockCompressedFile)) { // write lines until we exceed the size of the first block (block address != 0) do { bcos.write("Write this line enough times to exceed the size or a compressed block\n".getBytes()); } while (BlockCompressedFilePointerUtil.getBlockAddress(bcos.getFilePointer()) == 0); sentinelLineOffset = bcos.getFilePointer(); // write a terminating line that is guaranteed to not be in the first block bcos.write(sentinelLine.getBytes()); } return sentinelLineOffset; } }
@Test public void testOverflow() throws Exception { final File f = File.createTempFile("BCOST.", ".gz"); f.deleteOnExit(); final List<String> linesWritten = new ArrayList<>(); System.out.println("Creating file " + f); final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(f); Random r = new Random(15555); final int INPUT_SIZE = 64 * 1024; byte[] input = new byte[INPUT_SIZE]; r.nextBytes(input); bcos.write(input); bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f); byte[] output = new byte[INPUT_SIZE]; int len; int i = 0; while ((len = bcis.read(output, 0, output.length)) != -1) { for (int j = 0; j < len; j++) { Assert.assertEquals(output[j], input[i++]); } } Assert.assertEquals(i, INPUT_SIZE); bcis.close(); }
final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(f, 5, myDeflaterFactory); String s = "Hi, Mom!\n"; bcos.write(s.getBytes()); //Call 1 linesWritten.add(s); s = "Hi, Dad!\n"; bcos.write(s.getBytes()); //Call 2 linesWritten.add(s); bcos.flush(); linesWritten.add(s); bcos.write(sb.toString().getBytes()); //Call 3 bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f);
final BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(f); String s = "Hi, Mom!\n"; bcos.write(s.getBytes()); linesWritten.add(s); s = "Hi, Dad!\n"; bcos.write(s.getBytes()); linesWritten.add(s); bcos.flush(); linesWritten.add(s); bcos.write(sb.toString().getBytes()); bcos.close(); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(f);