Read source info from given InputStream. The stream is guaranteed to be
closed.

@param inputStream
the InputStream
@throws IOException
if an I/O error occurs, or if the format is invalid
766858
public void read(@WillClose InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(Util.getReader(inputStream));

        int lineNumber = 0;
        try {
            String line;
            int lparen;
            String version;

            while ((line = reader.readLine()) != null) {
                ++lineNumber;

                if (lineNumber == 1) {
                    if (DEBUG) {
                        System.out.println("First line: " + line);
                    }
                    // Try to parse the version number string from the first
                    // line.
                    // null means that the line does not appear to be a version
                    // number.
                    version = parseVersionNumber(line);
                    if (version != null) {
                        // Check to see if version is supported.
                        // Only 1.0 supported for now.
                        if (!"1.0".equals(version)) {
                            throw new IOException("Unsupported sourceInfo version " + version);
                        }

                        // Version looks good. Skip to next line of file.
                        continue;
                    }
                }

                StringTokenizer tokenizer = new StringTokenizer(line, ",");

                String className = tokenizer.nextToken();
                String next = tokenizer.nextToken();
                if (DIGITS.matcher(next).matches()) {
                    // Line number for class
                    SourceLineRange range = createRange(next, tokenizer.nextToken());
                    classLineMap.put(className, range);
                    if (DEBUG) {
                        System.out.println("class:" + className + "," + range);
                    }
                } else if ((lparen = next.indexOf('(')) >= 0) {
                    // Line number for method
                    String methodName = next.substring(0, lparen);
                    String methodSignature = next.substring(lparen);

                    if ("init^".equals(methodName)) {
                        methodName = "<init>";
                    } else if ("clinit^".equals(methodName)) {
                        methodName = "<clinit>";
                    }

                    SourceLineRange range = createRange(tokenizer.nextToken(), tokenizer.nextToken());
                    methodLineMap.put(new MethodDescriptor(className, methodName, methodSignature), range);
                    if (DEBUG) {
                        System.out.println("method:" + methodName + methodSignature + "," + range);
                    }
                } else {
                    // Line number for field
                    String fieldName = next;
                    SourceLineRange range = createRange(tokenizer.nextToken(), tokenizer.nextToken());
                    fieldLineMap.put(new FieldDescriptor(className, fieldName), range);
                    if (DEBUG) {
                        System.out.println("field:" + className + "," + fieldName + "," + range);
                    }
                }

                // Note: we could complain if there are more tokens,
                // but instead we'll just ignore them.
            }
        } catch (NoSuchElementException e) {
            IOException ioe = new IOException("Invalid syntax in source info file at line " + lineNumber);
            ioe.initCause(e);
            throw ioe;
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
339989
@Override
    public void close()
        throws IOException
    {
        InputStream in = _inputSource;

        if (in != null) {
            _inputSource = null;
            if (_autoClose) {
                in.close();
            }
        }
        freeBuffers();
    }
522979
@Override
    public int read(byte[] output, int offset, int length) throws IOException {
        
        //Return -1 here because if we are closed or finished, we're at the end of the stream
        if(isClosed || isFinished()){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Nothing to read, stream is closed : " + isClosed + ", or finished : " + isFinished());
            return -1;
        }        
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "read" , "SRTInputStream31.read(byte[], int, int)");
        }
        
        if(output == null){
            if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                Tr.error(tc, "read.write.bytearray.null");
            throw new NullPointerException(Tr.formatMessage(tc, "read.write.bytearray.null"));
        }
        if((offset < 0) || (length < 0) || (length > (output.length - offset))){
            if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                Tr.error(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length});
            throw new IndexOutOfBoundsException(Tr.formatMessage(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length}));
        }
        
        int returnSize = 0;
        
        if(this.request.isAsyncStarted() && (this.getReadListener()!= null)){
            synchronized(this){
                //Check if isReady had returned false. If it did then an IllegalArgumentException will be thrown if a listener is set
                isReadyFalseCheck();
                
                returnSize = super.read(output, offset, length);
            }
        } else{
            returnSize = super.read(output, offset, length);
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "read" , "SRTInputStream31.read(byte[], int, int) : " + returnSize);
        }
        
        return returnSize;
    }
29758
@Override
  public void handleStream(final InputStream inputStream) {
    if (executorService.isShutdown()) {
      throw new IllegalStateException("Cannot re-use " + this.getClass().getName());
    }
    result.setFuture(executorService.submit(() -> consumeBytes(inputStream)));
    executorService.shutdown();
  }
524961
public static void close(final InputSource input) throws IOException {
        if (input != null) {
            final InputStream i = input.getByteStream();
            if (i != null) {
                i.close();
            } else {
                final Reader w = input.getCharacterStream();
                if (w != null) {
                    w.close();
                }
            }
        }
    }
1035438
private void read(InputStream is, Table table) throws IOException
   {
      byte[] buffer = new byte[m_definition.getPageSize()];
      while (true)
      {
         int bytesRead = is.read(buffer);
         if (bytesRead == -1)
         {
            break;
         }

         if (bytesRead != buffer.length)
         {
            throw new IOException("Unexpected end of file");
         }

         readPage(buffer, table);
      }
   }
726612
@Override
	public void load(final InputStream inStream) throws IOException {
		lock.writeLock().lock();
		try {
			properties.load(inStream);
		} finally {
			lock.writeLock().unlock();
		}
	}
345007
public void readFrom(InputStream is) throws IOException {
        while(true) {
            if(count==buf.length) {
                // reallocate
                byte[] data = new byte[buf.length*2];
                System.arraycopy(buf,0,data,0,buf.length);
                buf = data;
            }

            int sz = is.read(buf,count,buf.length-count);
            if(sz<0)     return;
            count += sz;
        }
    }
537643
public InputStream openInputStream()
    throws IOException
  {
    close();

    TempBuffer head = _head;
    _head = null;
    _tail = null;

    return new TempInputStream(head);
  }
623164
public static String read(InputStream in) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int length = 0;
        while ((length = in.read(buffer)) != -1) {
            baos.write(buffer, 0, length);
        }
        return new String(baos.toByteArray());
    }
628345
public static Experiment readExperiment(final InputStream inputStream) throws IOException {
        checkNotNull(inputStream);
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
            return readExperiment(reader);
        }
    }
227358
public void read(InputStream is) throws IOException
   {
      byte[] headerBlock = new byte[20];
      is.read(headerBlock);

      int headerLength = PEPUtility.getShort(headerBlock, 8);
      int recordCount = PEPUtility.getInt(headerBlock, 10);
      int recordLength = PEPUtility.getInt(headerBlock, 16);
      StreamHelper.skip(is, headerLength - headerBlock.length);

      byte[] record = new byte[recordLength];
      for (int recordIndex = 1; recordIndex <= recordCount; recordIndex++)
      {
         is.read(record);
         readRow(recordIndex, record);
      }
   }
725114
public static void copyStream( File inputFile, OutputStream os ) throws IOException {
		InputStream is = new FileInputStream( inputFile );
		try {
			copyStreamUnsafelyUseWithCaution( is, os );
		} finally {
			is.close();
		}
	}
863628
public void close()
        throws IOException
    {
        InputStream is = _is;
        _is = null;

        if (is != null)
            is.close();

        _state.println();
    }
66560
public void setInputStream(InputStream stream) {
        try {
            cachedInputStream = new ByteArrayOutputStream();
            IOUtils.copy(stream, cachedInputStream);
        } catch (IOException e) {
            LOG.error("Exception on writing InputStream.", e);
        }
    }
578542
private String readLine(InputStream stream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        return reader.readLine();
    }
53051
protected int readWord(InputStream inputStream) throws IOException {
        byte[] bytes = new byte[2];
        boolean success = inputStream.read(bytes) == 2;
        return !success ? -1 : readWord(bytes, 0);
    }