Code example for OutputStream

Methods: close, write

0
	public void testNegative() throws IOException { 
		Bucket bucket = makeBucket(Math.max(DATA1.length, DATA2.length));
		try { 
			// Write 
			OutputStream os = bucket.getOutputStream();
			os.write(0);
			os.write(-1);
			os.write(-2);
			os.write(123);
			os.close();
 
			// Read byte[] 
			InputStream is = bucket.getInputStream();
			assertEquals("Write-0", 0xff & (byte) 0, is.read());
			assertEquals("Write-1", 0xff & (byte) -1, is.read());
			assertEquals("Write-2", 0xff & (byte) -2, is.read());
			assertEquals("Write-123", 0xff & (byte) 123, is.read());
			assertEquals("EOF", -1, is.read());
			is.close();
		} finally { 
			freeBucket(bucket);