Same as {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} with the input
stream being a stream to read the file.

@throws FileNotFoundException if the file does not exist
555618
public MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, File file,
            Map<String, String> headers) throws JMSException, FileNotFoundException {
        return sendWithBinaryData(context, basicMessage, new FileInputStream(file), headers);
    }
982449
@Override
    public void readExternal(ObjectInput s) throws IOException, ClassNotFoundException {
        String type = (String) s.readObject();
        String endian = (String) s.readObject();

        // read in serialized data
        byte[] bytes = (byte[]) s.readObject();

        if (type.equals("ND")) {
            // wrap the bytes into a non-direct buffer. We don't want to
            // get the ByteBuffer from the pool since we would have to copy the
            // bytes from this byte array into the new ByteBuffer.
            // wrap will use a non-direct ByteBuffer
            this.oByteBuffer = ByteBuffer.wrap(bytes);
            if (endian.equals("B")) {
                this.oByteBuffer.order(java.nio.ByteOrder.BIG_ENDIAN);
            } else {
                this.oByteBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            }
        } else {
            // allocate a Direct Buffer. Do not allocate from a pool since
            // determining the code responsible for releasing the buffer is
            // not clear.
            this.oByteBuffer = ByteBuffer.allocateDirect(bytes.length);

            // Set endian before reading from the buffer
            if (endian.equals("B")) {
                this.oByteBuffer.order(java.nio.ByteOrder.BIG_ENDIAN);
            } else {
                this.oByteBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            }
            this.oByteBuffer.put(bytes);
        }

        this.oByteBuffer.position(Integer.parseInt((String) s.readObject()));
        this.oByteBuffer.limit(Integer.parseInt((String) s.readObject()));

        String rOnly = (String) s.readObject();
        if (rOnly.equals("R")) {
            this.readOnly = true;
        } else {
            this.readOnly = false;
        }

        // 262860 New buffer will need the Pool Manager for duplicates/slices
        this.oWsByteBufferPoolManager = (WsByteBufferPoolManagerImpl) WsByteBufferPoolManagerImpl.getRef();
        this.trusted = this.oWsByteBufferPoolManager.isTrustedUsers();

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "readExternal:  trusted set to: " + this.trusted);
        }
        // If we can serialize, then this was/is true.
        this.removedFromLeakDetection = true;
    }
1136118
public ChannelFuture respondBinary(ByteBuf byteBuf) throws Exception {
        if (HttpUtil.isTransferEncodingChunked(response)) {
            respondHeadersOnlyForFirstChunk();
            return channel.writeAndFlush(new DefaultHttpContent(byteBuf));
        } else {
            if (!response.headers().contains(CONTENT_TYPE))
                response.headers().set(CONTENT_TYPE, "application/octet-stream");

            response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
            response.content().writeBytes(byteBuf);
            return respond();
        }
    }
674055
public InputStream getData() {
    if (data != null) {
      return new ByteArrayInputStream(data);
    } else if (dataStream != null) {
      return dataStream;
    } else {
      throw new IllegalStateException("Either the byte[] or the stream mustn't be null at this point.");
    }
  }
540774
public static OutputStream toFile(File file) throws FileNotFoundException {
		if(file != null) {
			return new FileOutputStream(file);
		}
		return null;
	}
593568
@Override
  public void writeBinaryData(byte []sBuf, int sOffset, int sLength)
  {
    byte []tBuf = _buffer;
    int tOffset = _offset;
    int tLength = tBuf.length;
    
    int end = sOffset + sLength;
    
    while (sOffset < end) {
      if (tLength - tOffset < 1) {
        tOffset = flush(tOffset);
      }
      
      int sublen = Math.min(tLength - tOffset, end - sOffset);
      
      System.arraycopy(sBuf, sOffset, tBuf, tOffset, sublen);
      
      tOffset += sublen;
      sOffset += sublen;
    }
    
    _offset = tOffset;
  }
608208
@Override
    public InputStream getBinaryStream(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            return new ByteArrayInputStream(
                    table.getStringAsBytes(columnIndex - 1));
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
914448
private ProjectFile readDatabaseFile(InputStream inputStream) throws MPXJException
   {
      ProjectReader reader = new AstaDatabaseFileReader();
      addListeners(reader);
      return reader.read(inputStream);
   }
1132876
public WebSocketInputStream initBinary()
    throws IOException
  {
    if (_binaryIn == null) {
      _binaryIn = new WebSocketInputStream(this);
    }

    _binaryIn.init();

    return _binaryIn;
  }
156833
public synchronized InputStream getInputStream() throws IOException {
        if (!connected) {
            connect();
        }

        // Nothing to return
        if (responseCode == HTTP_NOT_FOUND) {
            throw new FileNotFoundException(url.toString());
        }
        int length;

        if (inputStream == null) {
            return null;
        }

        // "De-chunk" the output stream
        else if ("chunked".equalsIgnoreCase(getHeaderField("Transfer-Encoding"))) {
            if (!(inputStream instanceof ChunkedInputStream)) {
                inputStream = new ChunkedInputStream(inputStream);
            }
        }

        // Make sure we don't wait forever, if the content-length is known
        else if ((length = getHeaderFieldInt("Content-Length", -1)) >= 0) {
            if (!(inputStream instanceof FixedLengthInputStream)) {
                inputStream = new FixedLengthInputStream(inputStream, length);
            }
        }
        return inputStream;
    }
1292794
protected void read(ObjectInputStream s) throws IOException, ClassNotFoundException {
        val header = BaseDataBuffer.readHeader(s);
        data = Nd4j.createBuffer(header.getRight(), length, false);

        data.read(s, header.getLeft(), header.getMiddle(), header.getRight());
    }
518491
protected Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage,
            InputStream inputStream) throws JMSException {
        return createMessageWithBinaryData(context, basicMessage, inputStream, null);
    }
699823
@SuppressWarnings("resource")
    public InputStream getInputStream(String filename)
    {
        InputStream streamIn = null;
        if (filename.indexOf(':') == -1)
        {
            String filepath = ((BaseHttpTask)this.getTask()).getRealPath(this.getServletRequest(), filename);
            if (filepath != null)
            {
	            File file = new File(filepath);
	            try   {
	                streamIn = new FileInputStream(file);
	            } catch (FileNotFoundException ex)  {
	                streamIn = null;
	            }
            }
        }
        if (streamIn == null)
            streamIn = Utility.getInputStream(filename, this.getApplication());
        return streamIn;
    }
962179
public static void transfer(final InputStream input,
			final OutputStream output) throws Exception {
		final byte[] data = new byte[SIZE];
		while (true) {
			final int count = input.read(data, 0, SIZE);
			if (count == EOF) {
				break;
			}
			output.write(data, 0, count);
		}
	}
707498
public void readData(InputStream inputStream) throws IOException {
        if (inputStream == null) {
            return;
        }

        data = ParserUtils.parseBinary(inputStream, (int) size.getValue());
    }
982435
public static InputStream readFileToInputStream(String filePath)
            throws FileNotFoundException {

        InputStream is = null;

        try {

            is = new FileInputStream(filePath);

            logger.info("Completed read file for input stream " + " Path: "
                    + filePath + " at " + PcDateUtils.getNowDateTimeStr());

        } catch (Exception e) {
            logger.error("Error read file." + e);
        }
        return is;

    }
252326
private InputStream getInputStreamFromFile(File f) throws FileNotFoundException{
		InputStream stream = null;



		if ( cacheRawFiles ){
			stream = FlatFileCache.getInputStream(f.getAbsolutePath());

			if ( stream == null){
				FlatFileCache.addToCache(f.getAbsolutePath(),f);
				stream = FlatFileCache.getInputStream(f.getAbsolutePath());
			}
		}

		if ( stream == null)
			stream = new FileInputStream(f);

		return stream;
	}