Java 8 MemoryCacheImageOutputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MemoryCacheImageOutputStream class.

This code example shows how to use the following methods:readInt, seek, length
        assertEquals(value, tiffLong.getValue());
    } 
 
    public void testWriteToStream() throws IOException {
        final TiffLong tiffLong = new TiffLong(_TIFFLONG_MAX);
        final MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(new ByteArrayOutputStream());
 
        tiffLong.write(stream);
 
        assertEquals(4, stream.length());
        stream.seek(0);
        assertEquals(0xffffffff, stream.readInt());
    } 
 
    public void testGetSizeInBytes() { 
        final TiffLong tiffLong = new TiffLong(234);
        assertEquals(4, tiffLong.getSizeInBytes());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:readShort, seek, length
        assertEquals(value, tiffShort.getValue());
    } 
 
    public void testWriteToStream() throws IOException {
        final TiffShort tiffShort = new TiffShort(_TIFFSHORT_MAX);
        final MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(new ByteArrayOutputStream());
 
        tiffShort.write(stream);
 
        assertEquals(2, stream.length());
        stream.seek(0);
        assertEquals((short) 0xffff, stream.readShort());
    } 
 
    public void testGetSizeInBytes() { 
        final TiffShort tiffShort = new TiffShort(234);
        assertEquals(2, tiffShort.getSizeInBytes());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:writeBytes
    private CeosFileReader _reader;
 
    @Override 
    protected void setUp() throws Exception {
        final ByteArrayOutputStream os = new ByteArrayOutputStream(24);
        _ios = new MemoryCacheImageOutputStream(os);
        _prefix = "ImageRecordTest_prefix";
        _ios.writeBytes(_prefix);
        writeRecordData(_ios);
        _ios.writeBytes("ImageRecordTest_suffix"); // as suffix
        _reader = new CeosFileReader(_ios);
    } 
 
    public void testInit_SimpleConstructor() throws IOException,
                                                    IllegalCeosFormatException { 
        _reader.seek(_prefix.length());
 
        final ImageRecord record = new ImageRecord(_reader);
 
        assertRecord(record);
6
CodeRank
This code example shows how to use the following methods:writeBytes
    private CeosFileReader _reader;
 
    @Override 
    protected void setUp() throws Exception {
        final ByteArrayOutputStream os = new ByteArrayOutputStream(24);
        _ios = new MemoryCacheImageOutputStream(os);
        _prefix = "TextRecordTest_prefix";
        _ios.writeBytes(_prefix);
        writeRecordData(_ios);
        _ios.writeBytes("TextRecordTest_suffix"); // as suffix
        _reader = new CeosFileReader(_ios);
    } 
 
    public void testInit_SimpleConstructor() throws IOException, IllegalCeosFormatException {
        _reader.seek(_prefix.length());
        final TextRecord textRecord = new TextRecord(_reader);
 
        assertRecord(textRecord);
    } 
 
6
CodeRank
This code example shows how to use the following methods:
	private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
		if (this.cacheDir != null) {
			return new FileCacheImageOutputStream(os, this.cacheDir);
		} 
		else { 
			return new MemoryCacheImageOutputStream(os);
		} 
	} 
 
 
	/** 
	 * Template method that allows for manipulating the {@link ImageReadParam} 
	 * before it is used to read an image. 
	 * <p>The default implementation is empty. 
	 */ 
	protected void process(ImageReadParam irp) {
	} 
 
	/** 
	 * Template method that allows for manipulating the {@link ImageWriteParam} 
6
CodeRank
This code example shows how to use the following methods:readInt, seek, length
 
    public void testWriteToStream() throws IOException {
        final long numerator = _TIFFRATIONAL_MAX;
        final long denominator = _TIFFRATIONAL_MAX - 3;
        final TiffRational tiffRational = new TiffRational(numerator, denominator);
        final MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(new ByteArrayOutputStream());
 
        tiffRational.write(stream);
 
        assertEquals(8, stream.length());
        stream.seek(0);
        assertEquals((int) numerator, stream.readInt());
        assertEquals((int) denominator, stream.readInt());
    } 
 
    public void testGetSizeInBytes() { 
        final TiffRational tiffRational = new TiffRational(234, 23478);
        assertEquals(8, tiffRational.getSizeInBytes());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getStreamPosition, writeBytes
public class CommonFileDescriptorRecordTest extends TestCase {
 
    public void testInitCommonFileDescriptorRecord() throws IOException,
                                                            IllegalCeosFormatException { 
        final ByteArrayOutputStream os = new ByteArrayOutputStream(24);
        final ImageOutputStream ios = new MemoryCacheImageOutputStream(os);
        final String prefix = "fdkjglsdkfhierr.m b9b0970w34";
        ios.writeBytes(prefix);
        writeRecordData(ios);
        ios.writeBytes("nq3tf9ß8nvnvpdi er 0 324p3f"); // as suffix
 
        final CommonFileDescriptorRecord record = new CommonFileDescriptorRecord(new CeosFileReader(ios),
                                                                                 prefix.length());
 
        assertRecord(record);
        assertEquals(prefix.length(), record.getStartPos());
        assertEquals(prefix.length() + 180, ios.getStreamPosition());
    } 
 
    public static void assertRecord(final CommonFileDescriptorRecord record) {

6
CodeRank
This code example shows how to use the following methods:flush
 
    public void testWrite() throws Exception {
        final GeoTiffAscii tiffAscii = new GeoTiffAscii("Alois und Sepp");
 
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        final MemoryCacheImageOutputStream ios = new MemoryCacheImageOutputStream(os);
        tiffAscii.write(ios);
        ios.flush();
        assertEquals("Alois und Sepp|\u0000", os.toString());
    } 
 
    public void testGetSizeInBytes() { 
        final String value = "Hedi und Fredi";
        final GeoTiffAscii geoTiffAscii = new GeoTiffAscii(value);
        assertEquals(value.length() + 2, geoTiffAscii.getSizeInBytes());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getStreamPosition, writeBytes
        assertEquals(prefix.length() + 6 * 3, _ios.getStreamPosition());
    } 
 
    public void testReadInArrayWithBlanks() throws IOException, IllegalCeosFormatException {
        final String prefix = "vspdfoperilfdkposnsern";
        _ios.writeBytes(prefix);
        _ios.writeBytes("123 45 67"); // 9 ints with length 1
        _ios.writeBytes("suffix");
 
        final CeosFileReader ceosReader = new CeosFileReader(_ios);
        ceosReader.seek(prefix.length());
        final int[] ints = ceosReader.readInArray(9, 1);
 
        assertNotNull(ints);
        assertEquals(9, ints.length);
        assertEquals(1, ints[0]);
        assertEquals(2, ints[1]);
        assertEquals(3, ints[2]);
        assertEquals(0, ints[3]);
        assertEquals(4, ints[4]);

6
CodeRank
This code example shows how to use the following methods:writeBytes
    private CeosFileReader _reader;
 
    @Override 
    protected void setUp() throws Exception {
        final ByteArrayOutputStream os = new ByteArrayOutputStream(24);
        _ios = new MemoryCacheImageOutputStream(os);
        _prefix = "fdkjglsdkfhierr.m b9b0970w34";
        _ios.writeBytes(_prefix);
        _reader = new CeosFileReader(_ios);
    } 
 
    public void testInitRecord_SimpleConstructor() throws IOException,
                                                          IllegalCeosFormatException { 
        writeRecordData(_ios);
        _ios.writeBytes("nq3tf9ß8nvnvpdi er 0 324p3f"); // suffix
        _reader.seek(_prefix.length());
 
        final Ancillary2Record record = createAncillary2Record(_reader);
 
        assertRecord(record);
6
CodeRank
See Code Examples for Java 8 MemoryCacheImageOutputStream Methods: