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
4
votes
2 answers

How to cast a wchar_t to a BYTE* in C

I want to cast a wchar_t variable to a BYTE * before sending it through a stream. I Have wchar_t val[] = L"abc"; and I try to cast using: BYTE * bytes = (BYTE *)val; I don't have all the characters when I read bytes; I only have the first…
Pis
  • 105
  • 1
  • 6
4
votes
2 answers

Writing out using a Bytebuffer returns differently from simple write out

I'm trying to write byte data to a file and part of optimizing it, I want to reduce the number of times I write out to the file. Currently, I'm using: try (RandomAccessFile out = new RandomAccessFile(file, "rw")) { for(int i = 0; i < totalPkts;…
Aboutblank
  • 697
  • 3
  • 14
  • 31
4
votes
2 answers

LibGDX Texture to ByteBuffer

I am trying to convert a Texture to a Pixmap in LibGDX so I can get all of the pixel data into a ByteBuffer for some experiments, and from what I can tell, I should be able to do this by doing the following : Pixmap pixmap =…
Shamrock
  • 436
  • 1
  • 8
  • 17
4
votes
3 answers

Equivalent of Java's "ByteBuffer.putType()" in C#

I am trying to format a byte array in C#, by porting a code from Java. In Java, the methods "buf.putInt(value);", buf.putShort, buf.putDouble, (and so forth) are used. However I don't know how to port this to C#. I have tried the MemoryStream class,…
Lazlo
  • 8,518
  • 14
  • 77
  • 116
4
votes
1 answer

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Im new to c# client and server application, im working on a file upload client and server application. i can successfully upload my file name and file data to the server from the client application. but when i try to implement a new textbox that…
Daryl
  • 95
  • 1
  • 2
  • 10
4
votes
1 answer

Write an integer in little endian

i have to write in a file 4bytes representing an integer in little endian (java use big endian) because an external c++ application have to read this file. My code don't write anything in te file but de buffer has data inside. why? my…
abogarill
  • 43
  • 1
  • 4
3
votes
4 answers

What's holding up my ByteBuffer from freeing?

I'm allocating a lot of byte buffers. After I'm done with them I set all reference to null. This is supposedly the "correct" way to release bytebuffers? Dereference it and let the GC clean it up ? I also call System.gc() to try and help it…
user697111
  • 2,232
  • 8
  • 29
  • 40
3
votes
2 answers

I/O Operation On Channels Using ByteBuffer - Performance Comparision

I want to perform I/O operation on channels using ByteBuffer. Finally I came up with three solutions: FileChannel inChannel = new FileInputStream("input.txt").getChannel(); FileChannel outChannel = new…
Majid Azimi
  • 5,575
  • 13
  • 64
  • 113
3
votes
1 answer

Android ZXING encode qr via BitMatrix --> store to byte[] --> insert to database

I have been playing around with zxing over the weekend, and have ran into a problem that I am unable to solve. I am using the working java code example at QR Code encoding and decoding using zxing, and am interested in converting the generated…
MRN
  • 193
  • 1
  • 12
3
votes
2 answers

java data types to byte array

I have a Java class public class MsgLayout{ int field1; String field2; long field3; } I have to write this object as a byte array in a Socket output stream. The three fields (instance variables) have a layout. i.e. field1 must occupy 1 byte, field2…
hoshang.varshney
  • 1,110
  • 3
  • 15
  • 26
3
votes
1 answer

FileChannel.write on Linux produces lots of garbage, but not on Mac

I am trying to limit the amount of garbage produced by my log library, so I coded a test to show me how much memory is FileChannel.write creating. The code below allocates ZERO memory on my Mac, but creates tons of garbage on my Linux box (Ubuntu…
TraderJoeChicago
  • 6,205
  • 8
  • 50
  • 54
3
votes
1 answer

How to convert from ByteBuffer to Integer and String?

I converted an int to a byte array using ByteBuffer's putInt() method. How do I do the opposite? So convert those bytes to an int? Furthermore, I converted a string to an array of bytes using the String's getBytes() method. How do I convert it the…
darksky
  • 20,411
  • 61
  • 165
  • 254
3
votes
1 answer

Java: Performance of ByteBuffer versus jdk.incubator.foreign (Panama) Foreign Memory methods (MemoryLayout/Segment)

Background I'm self-studying databases in my spare time, trying to learn by implementing one ground-up. One of the first things you have to implement is the underlying data format and storage mechanisms. In DB's, there is a structure called a…
Gavin Ray
  • 595
  • 1
  • 3
  • 10
3
votes
0 answers

Cannot copy from a TensorFlowLite tensor (StatefulPartitionedCall:0) with 10368 bytes to a Java Buffer with 324 bytes

I'm trying to make a handwritten text recognition android application on android studio. I converted my model into tensorflow lite and then uploaded that file in my application. Below Im sharing the code for the same... There are many log statements…
3
votes
2 answers

Need explanation of transferring binary data using Thrift rpc

Lets say I defined following Thrift service service FileResource { binary get_file(1:string file_name) } Here is the generated implementation which I cannot understand public ByteBuffer recv_get_file() throws org.apache.thrift.TException { …
alehro
  • 2,198
  • 2
  • 25
  • 41