Skip to content

Instantly share code, notes, and snippets.

@Dav1dde
Created January 10, 2013 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dav1dde/4498174 to your computer and use it in GitHub Desktop.
Save Dav1dde/4498174 to your computer and use it in GitHub Desktop.
public static byte[] readBytesFromStream(DataInputStream par0DataInputStream) throws IOException
{
short var1 = par0DataInputStream.readShort();
System.out.printf("\n\nLength is: %s\n", var1);
if (var1 < 0)
{
throw new IOException("Key was smaller than nothing! Weird key!");
}
else
{
byte[] var2 = new byte[var1];
int bytes_read = par0DataInputStream.read(var2);
System.out.printf("Bytes read: %s\n", bytes_read);
return var2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment