/** * Any necessary processing at the end of the file */ @Override public void close() { codec.close(); }
/** * Any necessary processing at the end of the file */ @Override public void close() { codec.close(); }
/** * Any necessary processing at the end of the file */ @Override public void close() { codec.close(); }
/** * Any necessary processing at the end of the file */ @Override public void close() { codec.close(); }
/** * Any necessary processing at the end of the file */ public void close() { codec.close(); }
public void close() { if (mStream != null) { mStream.close(); } if (mIndex != null) { mIndex.close(); } mStream = null; mFileHeader = null; mIndex = null; }
@Override protected void finish() { outputBinaryCodec.close(); try { if (bamIndexer != null) { bamIndexer.finish(); } } catch (Exception e) { throw new SAMException("Exception writing BAM index file", e); } }
@Override protected void finish() { outputBinaryCodec.close(); try { if (bamIndexer != null) { bamIndexer.finish(); } } catch (Exception e) { throw new SAMException("Exception writing BAM index file", e); } }
protected void finish() { outputBinaryCodec.close(); try { if (bamIndexer != null) { bamIndexer.finish(); } } catch (Exception e) { throw new SAMException("Exception writing BAM index file", e); } }
/** * close() must be called in order to flush any remaining buffered bytes. An unclosed file will likely be * defective. * */ @Override public void close() throws IOException { flush(); // For debugging... // if (numberOfThrottleBacks > 0) { // System.err.println("In BlockCompressedOutputStream, had to throttle back " + numberOfThrottleBacks + // " times for file " + codec.getOutputFileName()); // } codec.writeBytes(BlockCompressedStreamConstants.EMPTY_GZIP_BLOCK); codec.close(); // Can't re-open something that is not a regular file, e.g. a named pipe or an output stream if (this.file == null || !this.file.isFile()) return; if (BlockCompressedInputStream.checkTermination(this.file) != BlockCompressedInputStream.FileTermination.HAS_TERMINATOR_BLOCK) { throw new IOException("Terminator block not found after closing BGZF file " + this.file); } }
@Override public void close() { if (mCompressedInputStream != null) { try { mCompressedInputStream.close(); } catch (IOException e) { throw new RuntimeIOException("Exception closing compressed input stream.", e); } } if (mStream != null) { mStream.close(); } if (mIndex != null) { mIndex.close(); } mStream = null; mFileHeader = null; mIndex = null; }
/** * Closes any the open bfq file(s), if any, and opens the new one(s) * * @param fileIndex the index (counter) of the files to write */ private void initializeNextBfqFiles(final int fileIndex) { // Close the codecs if they were writing before if (codec1 != null) { codec1.close(); if (pairedReads) { codec2.close(); } } // Open new file, using the fileIndex. final File bfq1 = getOutputFile(this.outputPrefix , 1, fileIndex); codec1 = new BinaryCodec(IOUtil.openFileForWriting(bfq1)); log.info("Now writing to file " + bfq1.getAbsolutePath()); if (pairedReads) { final File bfq2 = getOutputFile(this.outputPrefix , 2, fileIndex); codec2 = new BinaryCodec(IOUtil.openFileForWriting(bfq2)); log.info("Now writing to file " + bfq2.getAbsolutePath()); } }
@Override public void close() { if (mCompressedInputStream != null) { try { mCompressedInputStream.close(); } catch (IOException e) { throw new RuntimeIOException("Exception closing compressed input stream.", e); } } if (mStream != null) { mStream.close(); } if (mIndex != null) { mIndex.close(); } mStream = null; mFileHeader = null; mIndex = null; }
@Test public void testReadAndWriteLong() throws IOException { final long value = 42; final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeLong(value); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(value, readCodec.readLong()); readCodec.close(); }
@Test public void testReadAndWriteFloat() throws IOException{ final float value = 42.5F; final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeFloat(value); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(value, readCodec.readFloat()); readCodec.close(); }
@Test public void testReadAndWriteDouble() throws IOException { final double value = 54.4; final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeDouble(value); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(value, readCodec.readDouble()); readCodec.close(); }
@Test public void testReadAndWriteInt() throws IOException { final int value = 42; //Writing to file final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeInt(value); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(value, readCodec.readInt()); readCodec.close(); }
@Test public void testReadAndWriteBoolean() throws IOException{ boolean values[] = {true, false}; for (boolean value : values) { final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeBoolean(value); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(value, readCodec.readBoolean()); readCodec.close(); } }
@Test public void testReadAndWriteString() throws IOException { final String value = "Test String to Write"; //Writing to file final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeString(value, true, false); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); final int stringLength = readCodec.readInt(); Assert.assertEquals(value.length(), stringLength); final String s = readCodec.readString(stringLength); Assert.assertEquals(value, s); readCodec.close(); }
@Test public void testReadAndWriteMutlitpleData() throws IOException{ final float fValue = 42.5F; final String sValue = "TestString"; final File outputFile = File.createTempFile(TEST_BASENAME, ".bin"); outputFile.deleteOnExit(); final OutputStream stream = new FileOutputStream(outputFile); final BinaryCodec codec = new BinaryCodec(stream); codec.writeFloat(fValue); codec.writeString(sValue, true, false); codec.close(); //Reading from file final InputStream instream = new FileInputStream(outputFile); final BinaryCodec readCodec = new BinaryCodec(instream); Assert.assertEquals(fValue, readCodec.readFloat()); final int stringLength = readCodec.readInt(); Assert.assertEquals(sValue, readCodec.readString(stringLength)); readCodec.close(); }