Code example for ByteArrayOutputStream

Methods: close, toByteArray

0
	         if (bitmap == null)
	         { 
	        	 sendActionFailedResult("screenshot failed to draw bitmap"); 
	        	 return; 
	         } 
        	 ByteArrayOutputStream stream = new ByteArrayOutputStream();
             bitmap.compress(Bitmap.CompressFormat.JPEG, 75, stream);
             stream.close();
             jpegBuffer = stream.toByteArray();
    	 } 
    	 catch (Exception exception)
    	 { 
    		 throw new TestFrameworkException("exception seen while getting bitmap", exception); 
		 } 
		  
		 if (jpegBuffer == null)
		 { 
			 sendActionFailedResult(errorMessage);
			 errorMessage = "Unknown error - no screenshot collected";
		 }