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

ImageIO faster than GZIPStream at max speed

I am looking for the fastest way to download an image from the GPU to a file, for later loading in the same application (so not necessarily PNG e.g.). I noticed however that when I use a DeflaterStream directly, it is considerably slower than…
RobotRock
  • 4,211
  • 6
  • 46
  • 86
0
votes
1 answer

Using a single ByteBuffer with multiple arrays in OpenGL

In my application, I'm having to draw multiple elements with OpenGL, some are Triangles and others are Line Strips. I'm putting my vertices into multiple float[] and my indices into multiple short[] whenever I am to draw a new shape. I also have to…
Adam
  • 2,532
  • 1
  • 24
  • 34
0
votes
2 answers

Equivalent of DataOutputStream.readBoolean and DataOutputStream.writeBoolean for ByteBuffer?

How can I do something like ByteBuffer.putBoolean and ByteBuffer.getBoolean? As with DataInputStream there is readBoolean and with DataOutputStream there is writeBoolean; I don't find the ability to write/read booleans with ByteBuffer. Is there a…
Jire
  • 9,680
  • 14
  • 52
  • 87
0
votes
1 answer

Java NIO SocketChannel read pre-defined bytes number

I have a Java NIO socket server. The server is getting JSONObjects from remote clients. i'm using the SocketChannel.read(ByteBuffer) method in order to read from the channel. each message ends with '\n' which marks the end of the current message. my…
Asaf Nevo
  • 11,338
  • 23
  • 79
  • 154
0
votes
2 answers

ByteBuffer.allocateDirect(size) is not creating backing byte[] in Android 2.2 emulator

I'm new to android. I can't seem to find pertinent forum posts. What has me stumped is that allocateDirect() does create the backing byte[] in Android 4.2 emulator. More specifically, I allocate a ByteBuffer, and call buffer.put(byte[]) several…
stephen
  • 1,039
  • 14
  • 31
0
votes
1 answer

Reading fields from bytearray

I am trying to send a message via tcp. Unfortunately that does not work and hence I have created the following code for test purposes: public void sendQuestion(String text) { // Set timestamp. SimpleDateFormat df = new…
user1809923
  • 1,235
  • 3
  • 12
  • 27
0
votes
1 answer

How to write and read a string property in a Java Object from a file with FileChannel and ByteBuffer

Following is a sample class showing how I put String into ByteBuffer. I am able to write String to a file like this, but I am not sure how can I know the size of byte array to read the title back again when deserializing. public class TestClass { …
Amit Gill
  • 35
  • 1
  • 7
0
votes
1 answer

StreamCorruptedException while reading an Object from ByteBuffer

I am using a java NIO Datagram Channel(in blocking mode). I want to transmit an object from one side to the other. This is what I do on the Sender Side: ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream…
Aditya
  • 195
  • 3
  • 4
  • 12
0
votes
1 answer

NIO Server/Client sending image problems

Hey guys i have been trying to make a NIO server/client program. My problem is that the server only sends 14 bytes then it won't send anything more. I've sat so long with this that i really can't see anything anymore and therefor decided to see if…
enoze
  • 35
  • 2
  • 8
0
votes
2 answers

ByteBuffer allocate and allocateDirect

I wondering when there is no memory available does allocateDirect and allocate from ByteBuffer will return null pointer or sth else ? (I was unable to find it in java docs). Thanks in advance.
zawart
  • 21
  • 1
0
votes
0 answers

How to convert array of strings to bytebuffer type?

I have a String array which i would like to convert to ByteBuffer type. I am using this code right now but i am not sure if its the correct way to do it. ByteBuffer.wrap(values.toString().getBytes()) Please let me know if this is the right…
kich
  • 734
  • 2
  • 9
  • 23
0
votes
1 answer

Conversion formula from decimal value to byte array not working

I have a formula in a specification for a binary file. The spec gives details of the meaning of the various bytes in the heading. In particular, one formula states this about 2 of the bytes: Byte 1 --> 7 6 5 4 3 2 1 0 Byte 2 --> 7 6 …
GLaDOS
  • 683
  • 1
  • 14
  • 29
0
votes
2 answers

int to bufferbyte

I have the following: byte[] l = ByteBuffer.allocate(16).putInt(N).array(); but it puts the bytes at the beggining of the array and not to the end of it how do i put it to the end? I've tried the following too: byte[] l =…
user1090694
  • 609
  • 4
  • 8
  • 16
0
votes
2 answers

Java Bytebuffer Filling up completely

I am currently using the Java ByteBuffer ByteBuffer batch = ByteBuffer.allocate(tuple_size * batch_size ) ; int pos = 0; int sent = 0; while ( sent++ < batch_size) { Event event = (Event) it.next(); …
user1018513
  • 1,682
  • 1
  • 20
  • 42
0
votes
1 answer

Reading from binary file and converting certain info to string

I have to read data from a binary file like S/W version,vendor etc. i have to show the output in a textarea.After reading the configurations the usre can send the selected file through a serial port. I have written some code here: InputStream…
lazyprogrammer
  • 633
  • 9
  • 26