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
3 answers

AsynchronousSocketChannel write/read all messages in one

Respect, I try to use new Java NIO2 to create Asynchronous SocketChannel on the client and on the server side and communicate, but problem is that all messages I sent to socket on the server, socket read all as one message. here is code: I create…
user2803095
  • 347
  • 1
  • 4
  • 16
0
votes
1 answer

could we read an object directly into the bytebuffer in java?

Say I have a List ls and I know its length could we allocate length*4 bytes for bytebuffer and use put to directlty read ls into the buffer?
user3495562
  • 335
  • 1
  • 4
  • 16
0
votes
2 answers

End of file using ByteBuffer and FileChannel

I write a small code, say ByteBuffer buffer = ByteBuffer.allocate(10); int w= fc.read(buffer); System.out.println(w); w= fc.read(buffer); System.out.println(w); w= fc.read(buffer); System.out.println(w); say the file contains 10 bytes, the result…
user3495562
  • 335
  • 1
  • 4
  • 16
0
votes
2 answers

How to see the contents of a file be written by BUfferbytes

WHen I use bufferbyte to input say integer 1 into the file, as .txt file, Filechanel fc (buffer.putInt(1)) fc.write(buffer). when I open it with text editor, it does not appear to be 1 there, but it could be read by buffer correctly. But…
user3495562
  • 335
  • 1
  • 4
  • 16
0
votes
0 answers

Why there is a confilict between what you see open a file and what input by ByteBuffer

for(int i=0; i<10; i++){ array[i] = (char)('a'+i); } RandomAccessFile rf = new RandomAccessFile("data1.txt", "rw"); FileChannel fc = rf.getChannel(); ByteBuffer buffer = null; buffer = ByteBuffer.allocate(1024); for(int…
user3495562
  • 335
  • 1
  • 4
  • 16
0
votes
1 answer

how to write a fixed number of bytes from a bytebuffer into the file in java

I allocate a big bytebuffer and read in some information (not use all the space associated with this buffer). Then I want to exactly input the used bytes into a file after filp(); what should I do. ByteBuffer buffer = new…
user3495562
  • 335
  • 1
  • 4
  • 16
0
votes
1 answer

MappedByteBuffer slow on initial run

long time reader, first time poster. I'm having a bit of trouble reading data quickly from a set of binary files. ByteBuffers and MappedBytBuffers offer the performance I require but they seem to require an initial run to warm up. I'm not sure if…
0
votes
2 answers

Faster way to read from Socket with ByteBuffer?

I have connected by TCP to a socket which is constantly sending a large amount of data, which I need to read in. What I have so far is a byte buffer that is reading byte by byte in a while loop. But the test case I am using right now is about 3 MB,…
G Boggs
  • 381
  • 1
  • 6
  • 19
0
votes
0 answers

How to do java.nio.Bytebuffer things on c# MemoryStream

I'm new to MemoryStream and I need to do buffer.get(byte array) buffer.flip() buffer.allocate(int) buffer.wrap(byte array) buffer.asReadOnlyBuffer() buffer.remaining() Any help would be greatly appreciated. here is what im using at the…
user3441843
  • 137
  • 1
  • 7
0
votes
1 answer

Best data structure for storing dynamically sized blocks from file input Java

I'm working on a Java program where I'm reading from a file in dynamic, unknown blocks. That is, each block of data will not always be the same size and the size is determined as data is being read. For I/O I'm using a MappedByteBuffer (the file…
marcman
  • 3,233
  • 4
  • 36
  • 71
0
votes
3 answers

How can I read a smaller ByteBuffer from a larger ByteBuffer?

Whilst the ByteBuffer.put(ByteBuffer) method is present, ByteBuffer.get(ByteBuffer) seems to be missing? How am I supposed to achieve reading a smaller ByteBuffer from a larger ByteBuffer?
Danny Rancher
  • 1,923
  • 3
  • 24
  • 43
0
votes
2 answers

inputStream.read() read wrong Boolean value

Sever code if(success){ out.write("true".getBytes().length); out.write("true".getBytes()); out.flush(); } else{ …
Lasith Malinga
  • 125
  • 1
  • 4
  • 11
0
votes
1 answer

Byte Conversion From Hex String Keeps Failing With Alphabet characters "G" and upwards in C#

I'm trying to build a simple XOR function that decrypts a hex key from a single character. It works with multiple characters and individual characters... but only from "A" through to "F". From "G" onwards, it keeps throwing a…
Dezzamondo
  • 2,169
  • 2
  • 20
  • 33
0
votes
2 answers

Getting unexpected Pixels from Raw Image

I am trying to catch R, G and B from some pixels on a game scene. For this I have created a Bitmap image in Black & White. This image is first loaded on Init(), afterwards, every sprite movement is checked for it is really an available spot. The…
RickON
  • 395
  • 7
  • 18
0
votes
1 answer

Reading pixel bytes from CFData: Arithmetic on a pointer to incomplete type

This code should get me each pixel's values starting from a CGImageRef: UIImage* image = [UIImage imageNamed:@"mask.bmp"]; CGImageRef aCGImageRef = image.CGImage; CFDataRef rawData =…
RickON
  • 395
  • 7
  • 18