edu.udayton.udri.asset.hikvision/src/edu/udayton/udri/asset/hikvision/HikVisionAsset.java
private byte[] writeImage() throws AssetException 
    {
        URL url = null;
        HttpURLConnection urlConnection = null;
        try
        {
            url = new URL(String.format(URL_IMAGE_CAPTURE, m_IpAddress));
            Logging.log(LogService.LOG_DEBUG, String.format(URL_IMAGE_CAPTURE, m_IpAddress));
        }
        catch (final MalformedURLException ex) 
        {
            Logging.log(LogService.LOG_ERROR, ex.getMessage());
            return new byte[]{0};
        }
        try
        {
            urlConnection = m_UrlUtil.getConnection(url);
        }
        catch (final IOException ex)
        {
            Logging.log(LogService.LOG_ERROR, ex.getMessage());
            return new byte[]{0};
        }        
        try (InputStream inStream = urlConnection.getInputStream())
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final int size = 1024; 
            final byte[] buffer = new byte[size];
            
            for (int readNum; (readNum = inStream.read(buffer)) != -1;) //NOCHECKSTYLE - avoid inner assignments
            {
                baos.write(buffer, 0, readNum);
            }
            
            final byte[] imageData = baos.toByteArray(); 
             
            baos.flush();
            baos.close();
            return imageData;            
        }
        catch (final IOException ex)
        {
            throw new AssetException(ex);
        }        
    }
/**
     * Gets the Image from the camera in the form of a byte array.
     * @return
     *     The byte array from the asset
     * @throws AssetException
     *     If the data received from the asset is valid or not
     */
Gets the Image from the camera in the form of a byte array.
@return
The byte array from the asset
@throws AssetException
If the data received from the asset is valid or not
Gets the Image from the camera in the form of a byte array . @return The byte array from the asset @throws AssetException If the data received from the asset is valid or not
private byte[] writeImage() throws AssetException 
    {
        URL url = null;
        HttpURLConnection urlConnection = null;
        try
        {
            url = new URL(String.format(URL_IMAGE_CAPTURE, m_IpAddress));
            Logging.log(LogService.LOG_DEBUG, String.format(URL_IMAGE_CAPTURE, m_IpAddress));
        }
        catch (final MalformedURLException ex) 
        {
            Logging.log(LogService.LOG_ERROR, ex.getMessage());
            return new byte[]{0};
        }
        try
        {
            urlConnection = m_UrlUtil.getConnection(url);
        }
        catch (final IOException ex)
        {
            Logging.log(LogService.LOG_ERROR, ex.getMessage());
            return new byte[]{0};
        }        
        try (InputStream inStream = urlConnection.getInputStream())
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final int size = 1024; 
            final byte[] buffer = new byte[size];
            for (int readNum; (readNum = inStream.read(buffer)) != -1;) 
            {
                baos.write(buffer, 0, readNum);
            }
            final byte[] imageData = baos.toByteArray(); 
            baos.flush();
            baos.close();
            return imageData;            
        }
        catch (final IOException ex)
        {
            throw new AssetException(ex);
        }        
    }
private byte [ ] writeImage ( ) throws AssetException { URL url = null ; HttpURLConnection urlConnection = null ; try { url = new URL ( String . format ( URL_IMAGE_CAPTURE , m_IpAddress ) ) ; Logging . log ( LogService . LOG_DEBUG , String . format ( URL_IMAGE_CAPTURE , m_IpAddress ) ) ; } catch ( final MalformedURLException ex ) { Logging . log ( LogService . LOG_ERROR , ex . getMessage ( ) ) ; return new byte [ ] { 0 } ; } try { urlConnection = m_UrlUtil . getConnection ( url ) ; } catch ( final IOException ex ) { Logging . log ( LogService . LOG_ERROR , ex . getMessage ( ) ) ; return new byte [ ] { 0 } ; } try ( InputStream inStream = urlConnection . getInputStream ( ) ) { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; final int size = 1024 ; final byte [ ] buffer = new byte [ size ] ; for ( int readNum ; ( readNum = inStream . read ( buffer ) ) != - 1 ; ) { baos . write ( buffer , 0 , readNum ) ; } final byte [ ] imageData = baos . toByteArray ( ) ; baos . flush ( ) ; baos . close ( ) ; return imageData ; } catch ( final IOException ex ) { throw new AssetException ( ex ) ; } }
Gets the Image from the camera in the form of a byte array.
Gets the Image from the camera in the form of a byte array .
//NOCHECKSTYLE - avoid inner assignments