Get report version from input stream to read report file

@param is
input stream
@return report version
557293
public static String getVersion(InputStream is) {
		try {
			String text = readAsString(is);
			return getVersionFromText(text);
		} catch (IOException e) {
			LOG.error(e.getMessage(), e);
			return null;
		}
	}
970724
static String getVersionForFile(final File file)  {
        try {
            final PluginMeta pluginMeta = loadMeta(file);
            return pluginMeta.getVersion();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
1293704
private Mat streamToMat(InputStream is) throws IOException {
        if(buffer == null){
            buffer = IOUtils.toByteArray(is);
            bufferMat = new Mat(buffer);
            return bufferMat;
        } else {
            int numReadTotal = is.read(buffer);
            //Need to know if all data has been read.
            //(a) if numRead < buffer.length - got everything
            //(b) if numRead >= buffer.length: we MIGHT have got everything (exact right size buffer) OR we need more data

            if(numReadTotal < buffer.length){
                bufferMat.data().put(buffer, 0, numReadTotal);
                bufferMat.cols(numReadTotal);
                return bufferMat;
            }

            //Buffer is full; reallocate and keep reading
            int numReadCurrent = numReadTotal;
            while(numReadCurrent != -1){
                byte[] oldBuffer = buffer;
                if(oldBuffer.length == Integer.MAX_VALUE){
                    throw new IllegalStateException("Cannot read more than Integer.MAX_VALUE bytes");
                }
                //Double buffer, but allocate at least 1MB more
                long increase = Math.max(buffer.length, MIN_BUFFER_STEP_SIZE);
                int newBufferLength = (int)Math.min(Integer.MAX_VALUE, buffer.length + increase);

                buffer = new byte[newBufferLength];
                System.arraycopy(oldBuffer, 0, buffer, 0, oldBuffer.length);
                numReadCurrent = is.read(buffer, oldBuffer.length, buffer.length - oldBuffer.length);
                if(numReadCurrent > 0){
                    numReadTotal += numReadCurrent;
                }
            }

            bufferMat = new Mat(buffer);
            return bufferMat;
        }

    }
592136
public String inputStreamToString(InputStream is, String charset) throws IOException {
        InputStreamReader isr = null;
        if (null == charset) {
            isr = new InputStreamReader(is);
        } else {
            isr = new InputStreamReader(is, charset);
        }
        StringWriter sw = new StringWriter();
        int c = -1;
        while ((c = isr.read()) != -1) {
            sw.write(c);
        }
        isr.close();
        return sw.getBuffer().toString();
    }
475140
public static final Date getDate(InputStream is) throws IOException
   {
      long timeInSeconds = getInt(is);
      if (timeInSeconds == 0x93406FFF)
      {
         return null;
      }
      timeInSeconds -= 3600;
      timeInSeconds *= 1000;
      return DateHelper.getDateFromLong(timeInSeconds);
   }
51393
public static final int getInt(InputStream is) throws IOException
   {
      byte[] data = new byte[4];
      is.read(data);
      return getInt(data, 0);
   }
690794
public static String readContent(InputStream is) {
    String ret = "";
    try {
      String line;
      BufferedReader in = new BufferedReader(new InputStreamReader(is));
      StringBuffer out = new StringBuffer();

      while ((line = in.readLine()) != null) {
        out.append(line).append(CARRIAGE_RETURN);
      }
      ret = out.toString();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return ret;
  }
741534
private static int readLogVersion(DataInputStream in) throws IOException {
    int logVersion = 0;
    in.mark(4);
    // See comments in EditLogFileInputStream as to why readLogVersion is
    // implemented in this way
    boolean available = true;
    try {
      logVersion = in.readByte();
    } catch (EOFException e) {
      available = false;
    }

    if (available) {
      in.reset();
      logVersion = in.readInt();
      if (logVersion < FSConstants.LAYOUT_VERSION) {
        throw new LedgerHeaderCorruptException(
            "Unexpected version of the log segment in the ledger: " + logVersion +
                ". Current version is " + FSConstants.LAYOUT_VERSION + ".");
      }
    }
    return logVersion;
  }
1254869
protected int readInt(InputStream is) throws IOException
   {
      byte[] data = new byte[4];
      if (is.read(data) != data.length)
      {
         throw new EOFException();
      }

      return (MPPUtility.getInt(data, 0));
   }
912305
private static byte[] readClass(final InputStream is) throws IOException {
        if (is == null) {
            throw new IOException("Class not found");
        }
        byte[] b = new byte[is.available()];
        int len = 0;
        while (true) {
            int n = is.read(b, len, b.length - len);
            if (n == -1) {
                if (len < b.length) {
                    byte[] c = new byte[len];
                    System.arraycopy(b, 0, c, 0, len);
                    b = c;
                }
                return b;
            }
            len += n;
            if (len == b.length) {
                byte[] c = new byte[b.length + 1000];
                System.arraycopy(b, 0, c, 0, len);
                b = c;
            }
        }
    }
154136
int readFromInputStream(byte[] buffer, InputStream is) {
    try {
      return is.read(buffer);
    } catch (IOException e) {
      if (END_OF_STREAM.equals(e.getMessage())) {
        return -2;
      }

      return Integer.MIN_VALUE;
    }
  }
892887
public static byte[] toByteArray(InputStream is) {
	    if (null == is) return null;
		try {
			return IOUtils.toByteArray(is);
		} catch (IOException e) {
			logger.error("toByteArray error", e);
		} finally {
		    try {
                is.close();
            } catch (IOException e) {
                logger.error("close stream error", e);
            }
		}
		return null;
	}
962106
public int readFrom(InputStream stream) throws IOException {
        int bytesRead = stream.read(buffer);
        if (bytesRead < 0) {
            bytesInBuffer = 0;
        } else {
            bytesInBuffer = bytesRead;
        }
        return bytesRead;
    }
647575
public static String geth2gisVersion() {
        try (InputStream fs = H2GISFunctions.class.getResourceAsStream("/org/h2gis/functions/system/version.txt")) {
            BufferedReader bufRead = new BufferedReader(new InputStreamReader(fs));
            StringBuilder builder = new StringBuilder();
            String line = null;
            while ((line = bufRead.readLine()) != null) {
                builder.append(line).append(" ");
            }
            return builder.toString();

        } catch (IOException ex) {
            return "unknown";
        }
    }
245782
public static ByteArrayOutputStream input2OutputStream(final InputStream is) {
        if (is == null) return null;
        try {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            byte[]                b  = new byte[MemoryConst.KB];
            int                   len;
            while ((len = is.read(b, 0, MemoryConst.KB)) != -1) {
                os.write(b, 0, len);
            }
            return os;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        } finally {
            IOKit.closeQuietly(is);
        }
    }
1205433
public <T> List<T> readCSV2Objects(InputStream is, Class<T> clazz) {

        try {
            return readCSVByMapHandler(is, clazz);
        } catch (Excel4JException | IOException e) {
            throw new Excel4jReadException("read CSV Error: ", e);
        }
    }
517806
public static final byte[] readAllBytes(InputStream is) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buf = new byte[4096];
        int rc = is.read(buf);
        while (rc != -1)
        {
            baos.write(buf, 0, rc);
            rc = is.read(buf);
        }
        return baos.toByteArray();
    }