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
-1
votes
1 answer

GSON and ByteBuffer.allocateDirect

We are trying to convert a Java Class instance to JSON by using GSON library. This class includes a ByteBuffer instance as a member that is created by allocateDirect. Due to the fact that ByteBuffer created by allocateDirect holds data in Native…
AGP
  • 459
  • 1
  • 6
  • 20
-1
votes
6 answers

Converting String to bytes in java

Possible Duplicate: Convert a string representation of a hex dump to a byte array using Java? I want to convert String "1B4322C2" in to bytes but problem is if I use getBytes() it will convert it into bytes with double the length of string and I…
Sandip Jadhav
  • 7,377
  • 8
  • 44
  • 76
-1
votes
1 answer

Java ByteBuffer to VB .NET

I have this java code : ByteBuffer p = ByteBuffer.allocate(packet.length - 10 + 14); p.order(ByteOrder.LITTLE_ENDIAN); p.putInt(packet.length); p.putInt(packet.request_id); p.putInt(packet.type); p.put(packet.paylod); …
-2
votes
1 answer

java ByteBuffer to int array conversion fails with UnsupportedOperationException

When converting a ByteBuffer to an int array java unexpectedly throws an UnsupportedOperationException. However as a byte array the information is correctly represented. int[] intArray = new int[]{1, 2}; ByteBuffer byteBuffer =…
Seb
  • 1,586
  • 1
  • 11
  • 15
-2
votes
1 answer

Save/Load file as byte buffer

So I have a line of code like this: func TestImage(){ img, _ := imgio.Open(`input.jpg`) inverted := effect.Invert(img) f, _ := os.Create("output.jpg") defer f.Close() Encoder := imgio.JPEGEncoder(80) Encoder(f,…
CSDD
  • 339
  • 2
  • 14
-2
votes
1 answer

How to parse a string into int

I am trying to execute git commands through Go code. I need to convert *byte.buffer value string to int. cmd := exec.Command("git", "cat-file", "-s", dir+":"filename) var outBuf bytes.Buffer var stderr = bytes.Buffer cmd.Stdout = &out cmd.Stferr =…
sngo
  • 1
-2
votes
1 answer

Why am I getting an ArraIndexOutOfBoundException?

I am trying to copy an byte array (fileData), which I read from a file, into another byte array (subdata) (below the code): ByteBuffer inputBuffer = decoderInputBuffers[intBufIndex]; int limit =…
-2
votes
1 answer

It is possible to expand a ByteBuffer created through the allocateDirect method?

Is there a way to increase allocated memory of off-heap ByteBuffer once it has created?
user12799249
-2
votes
1 answer

how to slice bytebuffer WITHOUT creating garbage

I am trying to use ByteBuffer as an internal storage for a class. I want to abstract the flip() and ByteBuffer manipulation from the caller but also do not want to use slice() as it creates additional garbage. Is there any alternative or design…
-2
votes
1 answer

What does "java.lang.IllegalArgumentException: src == this" mean?

I got the following exception when call java.nio.ByteBuffer.put(ByteBuffer.java) 11-09 22:11:55.631 E/AndroidRuntime( 1616): FATAL EXCEPTION: Thread-701 11-09 22:11:55.631 E/AndroidRuntime( 1616): Process: com.jerikc.demo, PID: 1616 11-09…
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
-2
votes
2 answers

Why can't I add a String to a ByteBuffer?

When I try to add the strings to a bytebuffer, it doesn't write in the file. While I try to add int and double it is working fine. But for strings it doesn't…
Mohankumar
  • 11
  • 1
  • 2
-2
votes
1 answer

Java's SocketChannel.read(ByteBuffer)

Cant seem to find the answer to this in the java docs: Does SocketChannel.read(ByteBuffer) append or overwrite the current ByteBuffer?
Verlix
  • 71
  • 4
-3
votes
1 answer

How to debug "Java NIO Socket Channel mismatch in size of sent and received bytes"?

Please look at this question. This is exact what I'm looking for but I didn't reach it yet. I'm sending multiple of images over a socketChannel. I try to attach the image size into a (cleared ByteBuffer) and attach then the image data into the same…
AppFell
  • 1
  • 1
-3
votes
1 answer

Netty ByteBuf receive-size != send-size

I have a little error wih my netty-server. I need to transfer different byteBuf sizes (the send-buffers capacity is dynamicly increased). byte[] buffer = text.getBytes(); byteBuffer.writeInt(buffer.length); if (byteBuffer.capacity() <…
Seb
  • 1
  • 2
-3
votes
1 answer

ImageIO write only load half the picture (socket)

I'm trying to send an image from client to server using socket. I am able to send the image to server directory, but the image sent is not full. What should I change? Client code : Part filePart = request.getPart("file"); InputStream fileContent =…
1 2 3
61
62