Create a new CodedInputStream wrapping the given byte array slice.
979426
public static CodedInputStream newInstance(final byte[] buf, final int off,
                                             final int len) {
    CodedInputStream result = new CodedInputStream(buf, off, len);
    try {
      // Some uses of CodedInputStream can be more efficient if they know
      // exactly how many bytes are available.  By pushing the end point of the
      // buffer as a limit, we allow them to get this information via
      // getBytesUntilLimit().  Pushing a limit that we know is at the end of
      // the stream can never hurt, since we can never past that point anyway.
      result.pushLimit(len);
    } catch (InvalidProtocolBufferException ex) {
      // The only reason pushLimit() might throw an exception here is if len
      // is negative. Normally pushLimit()'s parameter comes directly off the
      // wire, so it's important to catch exceptions in case of corrupt or
      // malicious data. However, in this case, we expect that len is not a
      // user-supplied value, so we can assume that it being negative indicates
      // a programming error. Therefore, throwing an unchecked exception is
      // appropriate.
      throw new IllegalArgumentException(ex);
    }
    return result;
  }
821259
private byte[] bytesWithInstanceCreationCaptured(byte[] bytes, String classToCall, String methodToCall) {
		ClassReader cr = new ClassReader(bytes);
		ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender(classToCall, methodToCall);
		cr.accept(ca, 0);
		byte[] newbytes = ca.getBytes();
		return newbytes;
	}
418478
def from_byte_array(cls, bytes_):
        
        runs = cls._length_run_coding.parse(bytes_)
        pixels = (run.pixels for run in runs.data)
        data = "".join(itertools.chain.from_iterable(pixels))
        return cls(data)
22022
public static InStream create(String name, ByteBuffer input, CompressionCodec codec,
      int bufferSize, boolean useVInts) throws IOException {
    if (codec == null) {
      return new UncompressedStream(name, input, useVInts);
    } else {
      return new CompressedStream(name, input, codec, bufferSize, useVInts);
    }
  }
1330589
public byte[] toByteArray() {
    try {
      final byte[] result = new byte[getSerializedSize()];
      final CodedOutputStream output = CodedOutputStream.newInstance(result);
      writeTo(output);
      output.checkNoSpaceLeft();
      return result;
    } catch (final IOException e) {
      throw new RuntimeException(
        "Serializing to a byte array threw an IOException " +
        "(should never happen).", e);
    }
  }
1066868
public static byte[] encode(InputStream in) {
        Base64OutputStream out = null;
        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            out = new Base64OutputStream(bytes);
            byte[] buf = new byte[4096];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            out.flush();
            return bytes.toByteArray();
        } catch (IOException e) {
            return null;
        } finally {
            try {
                in.close();
                if (out != null) out.close();
            } catch (IOException e) {
                throw new FaultException(e);
            }
        }
    }
883440
public static byte[] copyToByteArray(File in) throws IOException {
        assert in != null : "No input File specified";

        return copyToByteArray(new BufferedInputStream(new FileInputStream(in)));
    }
652136
public static IoBuffer wrap(byte[] byteArray, int offset, int length) {
    return wrap(ByteBuffer.wrap(byteArray, offset, length));
  }
45274
private static final Serializable deserialize(byte[] array, int offset, int length) throws IOException, ClassNotFoundException {  

	   ByteArrayInputStream byteArrayInputStream = null;
	  ObjectInputStream objectInputStream = null;
	  try {
          byteArrayInputStream = new ByteArrayInputStream(array, offset, length);
		  byteArrayInputStream.mark(array.length);
      	  objectInputStream = new ObjectInputStream(byteArrayInputStream);

		  return (Serializable) objectInputStream.readObject();
	  } catch (ClassNotFoundException cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }
	  } catch (NoClassDefFoundError cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }	    
	  } catch (StreamCorruptedException cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }
	  } finally { 
          if (byteArrayInputStream != null) {
              byteArrayInputStream.close();
          }
          if (objectInputStream != null) {
              objectInputStream.close();
          }
      }
   }
1025720
public static Slice wrappedShortArray(short[] array, int offset, int length)
    {
        if (length == 0) {
            return EMPTY_SLICE;
        }
        return new Slice(array, offset, length);
    }
196177
public static Packet fromStream(final DataInputStream in) throws IOException
    {
        // Packet Type
        final Packet.PacketType packetType = Packet.PacketType.fastValues[in.readByte()];

        // Packet ID
        final short packetID = in.readShort();

        // Data Length
        final int dataLength = in.readInt();

        // Data
        final byte[] data = new byte[dataLength];
        in.readFully(data);

        return new Packet(
                packetType,
                packetID,
                data
        );
    }
892147
public static Slice wrappedFloatArray(float[] array, int offset, int length)
    {
        if (length == 0) {
            return EMPTY_SLICE;
        }
        return new Slice(array, offset, length);
    }
595058
@NotNull
	@Contract("_ -> new")
	public static ByteBuf wrapForReading(@NotNull byte[] bytes) {
		return wrap(bytes, 0, bytes.length);
	}
167736
private byte[] createBytes(InputStream stream, long length) 
        throws SQLException {

        ByteArrayOutputStream buff = null;

        try {
            buff = new ByteArrayOutputStream();

            if (length > 0) IOUtils.copyLarge(stream, buff, 0, length);
            else IOUtils.copy(stream, buff);

            return buff.toByteArray();
        } catch (IOException e) {
            throw new SQLException("Fails to create BLOB", e);
        } finally {
            IOUtils.closeQuietly(buff);
        } // end of finally
    }
498748
private String zeroEndByteArrayToString(byte[] bytes) throws IOException
    {
        int i = 0;
        
        for ( i = 0; i < bytes.length && bytes[i] != 0; i++ );
        
        return new String( bytes, 0, i );
        
    }
488447
static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
            int offset, int limit, boolean bufferRecyclable, IOContext context)
            throws IOException
    {
        return new UTF8StreamJsonParser(context,
                DEFAULT_JSON_FACTORY.getParserFeatures(), in,
                DEFAULT_JSON_FACTORY.getCodec(),
                DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(1),
                buf, offset, limit, bufferRecyclable);
    }
1140324
public static Slice wrappedDoubleArray(double[] array, int offset, int length)
    {
        if (length == 0) {
            return EMPTY_SLICE;
        }
        return new Slice(array, offset, length);
    }