byte

Java: How to "trim" a byte array?

So I have some code that reads a certain amount of bytes from a file and returns the resulting byte array (this is basically used for chunking up files to send over the network as (eventually) base64-encoded ascii text). It works fine, except that when the last chunk of the file is generated, it isnt a full chunk. Therefore, the resulti...

How do I concatenate 2 bytes?

I have 2 bytes: byte b1 = 0x5a; byte b2 = 0x25; How do I get 0x5a25 ? ...

Java implicit conversion of int to byte

I am about to start working on something the requires reading bytes and creating strings. The bytes being read represent UTF-16 strings. So just to test things out I wanted to convert a simple byte array in UTF-16 encoding to a string. The first 2 bytes in the array must represent the endianness and so must be either 0xff 0xfe or 0xfe...

JSP download - application/octet-stream

I have a page in JSP that list some file that could be downloaded by a user. Thoses files are not on the local server, they are on a remote file server. When the user click to download a file, the webserver connect via TCP to the file server. The web server download the file and create a HTTP response for the client. Here is my code: ...

Convert integer into byte array (Java)

Hi, since Java doesn't provide a default way to do this, what's a fast way to convert an Integer into a Byte Array? e.g. 0xAABBCCDD => {AA, BB, CC, DD} ...

Converting random byte (0-255) to a float in PHP?

I am reading random bytes from /dev/urandom, and I want to make a random float out of it/them. How would I do this? I can convert the byte to a number with ord(), and it's between 0 and 255. It's obvious that 255 is 1.0, 127 is 0.5 and 0 is 0.0, but how do I calculate the rest? Also, I think one byte is not enough to give lots of preci...

UIImage to byte array

Hi Frineds, I am new in iPhone development. I want to convert an Image to Byte array. I tried to do this.But i didn't get any result. Please give me guideline for this problem. or provide me some tutorial regarding this problem... Thanks in Advance, Pathik Patel ...

How to Pass byte array as parameter in url in iPhone?

I am using following code to get bytes array. thx to this post. Data *data = [NSData dataWithContentsOfFile:filePath]; NSUInteger len = [data length]; Byte *byteData = (Byte*)malloc(len); memcpy(byteData, [data bytes], len); it is the right method to do so? Now, How i can pass bytes array into url? Thank You for Help, ...

How to return a byte[] doing chunking using remoting over http in C#?

In .Net remoting over http, we return a byte[] back to the client by doing a SerilizationInfo.AddValue(SerializationInfoValueName, ((MemoryStream)writer.BaseStream).GetBuffer(), typeof(byte[])) call. However, sometimes the byte[] size gets too big and causes an OutOfMemory exception. The only remedy seems to be utilize some form of chu...

What is the least number of bytes for representing date and time?

I need to transfer the current operating system's date and time up to micro-seconds accuracy from party A to party B over TCP/IP. What is the least number of bytes that can be used to represent this without sacrificing accuracy? And how to convert the date and time to your bytes format using C#? ...

VB.NET and bytes

I'm a little confused as to bytes. I can open a file in a hex editor and know that each 2 digits is a byte, they are 8 digits in binary correct? How are they stored in arrays in VB.NET? So if I have Dim xx() as byte = What would I put after the equals? The hex digits from the hex editor? (This is just a program I'm not going to save,...

java byte data type

In Sun' tutorial it says about a byte: byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where the...

[C#] Byte[] to String to Byte[] -- How to do so?

Ignore the reasons why someone would want to do this.... :) I want to be able to take some bytes, covert them to a string, then later back to the same byte array. Same length and everything. I've tried using the ASCIIEncoder class (works for only text files) and Unicode Encoder class (only works so far for arrays 1024*n big. I assume t...

reorganizing a series of 19 bytes into every single combination of any length

There are these 19 bytes (I am looking for combinations not the number of combinations) 17 00 00 00 A4 EA DB 13 02 00 00 00 00 00 00 A3 D3 02 CC I need any possible unique combination which matches these "rules": at least 4 bytes long the order of the bytes can't change(so 17 A3 D3 02 CC is ok but A3 D3 02 CC 17 isn't, because in th...

reading bytes in a file in vb.net

After getting the file name I create a new filestream and load all the bytes from the FileStream into a byte array, now I need to get certain bytes and store them in fields like the second 4 bytes are the time the file was created. When storing these in the variables should I store them as bytes or as string/integers/etc. Or have I done...

getting certain bytes from byte array in vb.net

I have a byte array containing bytes from a file(see my last question) now I want to get the second lot of 4 bytes from the array and convert them to an integer something like bytearray.get(4[start],4[length]) ...

getting 4 bytes from a byte array vb.net

I have a byte array and I need to get 4 bytes from it at a certain location(16) but I don't want to convert it to a integer or anything just keep it as 4 bytes to store in a variable. (I am sorry if this is too similar to my last question) ...

Passing bytes to "ParentClass" in vb.net

I have a class which get all the bytes from a file, then it splits up the bytes into three parts (a header, index and body) these 3 parts get passed along to 3 classes (called header, body and index) respectively. When the bytes in the three classes gets modified how can I pass these changes back up to the first class (the one that got ...

How to change the allowed amout of allocated memory?

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 40000 bytes) in /mounted-storage/home20a/sub001/sc20063-GJYD/[...] on line 62 It looks like the PHP-script only allowes me to allocate 32 MB to the memory? This was with an example image to test what would happen if a user tries to upload a huge picture. My...

Why does the xor operator on two bytes produce an int?

//key & hash are both byte[] int leftPos = 0, rightPos = 31; while(leftPos < 16) { //possible loss of precision. required: byte, found: int key[leftPos] = hash[leftPos] ^ hash[rightPos]; leftPos++; rightPos--; } Why would a bitwise operation on two bytes in...