Questions tagged [bytebuffer]

A binary buffer with no specific encoding. Use this tag only if you're having specific problems in relation with byte buffers

A binary buffer with no specific encoding.

Examples include byte[] in Java, char[] or uint8_t[] in C++. Objects like std::wstring_t that have a specific encoding (like UTF-8) assigned to them are no byte buffers.

Use this tag only if you're having specific problems in relation with byte buffers. Do not use this tag if there is no indication that the byte buffer you are using has any relation to the problem you're asking about.

919 questions
0
votes
1 answer

Disadvantage of a JNI call?

I'm reading the article here: http://www.kdgregory.com/?page=java.byteBuffer On that page, there is this section: In fact, the only reason that I can see for using direct buffers in a pure Java program is that they won't be moved during garbage…
soeske18
  • 115
  • 1
  • 6
0
votes
2 answers

Can TCP fragmentation be eliminated using a Pipe?

TCP network messages can be fragmented. But fragmented messages are difficult to parse, especially when data types longer than a byte are transferred. For example buffer.getLong() may fail if some bytes of the long I expect end up in a second…
XZS
  • 2,374
  • 2
  • 19
  • 38
0
votes
1 answer

Reading an int in java as a binary sequence using ByteBuffer

I'm trying to read an int (32 bits) to a bytebuffer object. I've used the method "Bytebuffer.allocate(4)", and I wish to take every 8 bits(1 byte) of the given int, into the bytebuffer object. How can I do this? (I need to use it in order to convert…
Tzur
  • 3
  • 2
0
votes
1 answer

How to convert byte array to double in java without using ByteBuffer

I want to convert a byte array to double and am doing this using the following code - double fromByteArraytoDouble(byte[] bytes) { return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getDouble(); } This code works, but I call this…
abhishek
  • 817
  • 6
  • 19
  • 33
0
votes
1 answer

How to process sequence of bytes in java?

I have stream of bytes and I need to form these bytes as a frame when I get particular Header. Example: Header: ABC Source: DFDFDFDF'ABC'IEJENFAREABCOEKRERIERE If ABC is detected, rest of the bytes 'IE' in a string and 'JEN' in a string and…
sathish
  • 1
  • 2
0
votes
1 answer

number of bytes written by putShort()

I want to write an enum value and store it to disk by saving a field from it with ByteBuffer.putShort() and writing that to disk. This enum is basically a field in a file header. How much space does ByteBuffer.putShort() occupy?
user1071840
  • 3,522
  • 9
  • 48
  • 74
0
votes
1 answer

How can I start a new Android activity without sending savedInstanceState?

I'm a new Android developer and I have a problem while starting a new activity which provide details of an item list. My first activity is listing all the applications installed on the smartphone. When I click on an item of this list, the second…
0
votes
2 answers

Convert Bitmap to ByteArray and vice versa

In my android application i want to convert image ,taken from camera, to byte array and convert back to bitmap to view in a image view. I can do it easily through Bitmap.compress. But i want to do it without Bitmap.compress. The problem is that i…
user2768215
  • 155
  • 2
  • 15
0
votes
2 answers

read 5 byte and store to long

I'am struggling again with type conversions in java... i need to read a 5 byte value from a ByteBuffer and store the value in a long. Therefore I did this: byte msb = b.get(); int lsb = b.getInt(); System.out.println(msb + " " + lsb); …
reox
  • 5,036
  • 11
  • 53
  • 98
0
votes
2 answers

What is the safest way to use direct byte buffers in Java?

Lets sat I have an object i'd like to store in a direct byte buffer. I'd like to able access parts of the object from the direct byte buffer without de-serializing the whole object. Is there a safe way to do this? I'm thinking you could somehow…
newlogic
  • 807
  • 8
  • 25
0
votes
1 answer

How to extract individual fields from byte array (which is in BIG-ENDIAN) in C++

I am tring to read couple of bytes from byteData as mentioned below in my C++ code. The actual value within byteData is a binary blob byte array in BIG-ENDIAN byte order format. So I cannot simply just "cast" the byte array into a String.. byteData…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
0
votes
1 answer

How to shift the bytes using Big Endian format instead of Little Endian in C++?

I am writing Byte Array value into a file using Java with Big Endian Byte Order format.. Now I need to read that file from C++ program... That Byte Array which I am writing into a file is made up of three Byte Arrays as described below- short…
arsenal
  • 23,366
  • 85
  • 225
  • 331
0
votes
1 answer

ByteBuffer returns null characters (character 0)

I'm trying to implement a simple client-server application, using NIO. As an exercise, communication should be text-based and line-oriented. But when the server reads the bytes sent by the client, it gets nothing, or rather, the buffer is filled…
afsantos
  • 5,178
  • 4
  • 30
  • 54
0
votes
1 answer

How to use ByteBuffer properly?

I am trying to use ByteBuffer properly with BigEndian byte order format.. I have couple of fields which I am trying to put together into a single ByteBuffer before storing it in Cassandra database. That Byte Array which I will be writing into…
arsenal
  • 23,366
  • 85
  • 225
  • 331
0
votes
2 answers

Java nio read bytebuffer from channel

How to receive the data from server example "cutting" in parcels of 1024 bytes, cause when the answer comes from server in packets like 2 parts I don't know how solve that. Ex. When the first packet arrives the size informed by the server is 1988…
Luciano Coelho
  • 89
  • 1
  • 11