Questions tagged [datainputstream]

A DataInputStream lets an application read primitive Java data types from an underlying input stream in a machine-independent way.

The DataInputStream class enables you to read Java primitives from InputStream's instead of only bytes. Wrap an InputStream in a DataInputStream and then you can read primitives from it. DataInputStreams represent Unicode strings in a format that is a slight modification of UTF-8.

339 questions
1
vote
0 answers

Java Different Methods Reading 32 Bit Float From InputStream

I have a problem reading 32Bit Float Values from an InputStream recieved from an API. The File-Format ist described in the API Documentation as: width x height x nbFrames 32-bit floating point pressure values, stored frame by frame and in…
1
vote
2 answers

DataInputStream read() always return -1

i have a client-server program in java where the client sends a request to the server and the server responds by sending a file. The connection with the server is made correctly and the first request sent by the client is correctly interpreted by…
JayJona
  • 469
  • 1
  • 16
  • 41
1
vote
0 answers

Unable to read whole Byte array from DataInputStream

I am trying to receive image in client socket of android from server socket of C# and C# server works fine for a C# client and the received image is exactly the same as the image sent. The problem is when i try to receive image in client socket of…
Bilal Hassan
  • 37
  • 1
  • 6
1
vote
2 answers

Why am I getting EOFException when trying to read DataInputStream?

I'm working on an assignment where I have to make a chat program using Java Socket's and Thread's and I can't get it to work. I'm getting EOFEception from a DataInputStream. From what I understand EOFException from DataInputStream means that the…
1
vote
0 answers

Java socket intermittent failure to read data

I have a integration test that sends 800 messages to a client. The client receives all the messages fine. The issue is my test fails periodically because the socket (towards the end of the messages), reads no bytes (-1) from the stream, closes the…
1
vote
1 answer

Client-Server multithreading chat app. client to client communication

So I have a homework assignment to create 2 clients on 1 server communicate on one server. Client 1 and Client 2 can communicate to the server but I need the 2 Clients to communicate to each and I am stumped?? I am pretty sure I'm on the right track…
1
vote
1 answer

Java Video Chat applicataion input output stream not working

I am making a video chat app which uses java networking (aka. sockets) to send images of the webcam to another client. My code sends first the length of the buffered image data then the actual data. The Server also reads first a int then the data…
Clement
  • 128
  • 11
1
vote
3 answers

How can I recognize a special delimiter string when reading from a file of strings?

I want to read strings from a file. When a certain string (><) is found, I want to start reading integers instead, and convert them to binary strings. My program is reading the strings in and saving them in an ArrayList successfully, but it does…
1
vote
1 answer

How to send serialized data over a TCP connection in java

I want to send data which i have serialized over a TCP connection. I have created a client/server connection and am sending an Object after serializing it. However, I dont know how should i read the data. here is the code snippet: SENDING…
Andy
  • 1,080
  • 5
  • 20
  • 35
1
vote
1 answer

Socket DataInputStream and EOF Flags : Is there a "conflict" when writing with istream.writeUTF after istream.write?

I am writing a program to transfer files between two computers, but I am not closing the socket for I am using the same socket to transfer other messages (like transfer server's folders organization). At a certain point, I have this code to transfer…
Ruan Kotovich
  • 579
  • 1
  • 4
  • 11
1
vote
2 answers

How to read zero-length file from /sys/fs/cgroup/ in Java?

I'd like to read the content of the /sys/fs/cgroup/ files (eg. cpuacct.usage) from Java. I've already implemented the reading algorithm based on this answer. The issue is that the cgroup files have 0 length by default. Each of the algorithms listed…
Alex
  • 258
  • 2
  • 20
1
vote
2 answers

java DataOutputStream getOutputStream() getInputStream()

one question in the case for example of DataOutputStream output= new DataOutputStream(clientSocket.getOutputStream()) ; or DataInputStream in = new DataInputStream(clientSocket.getInputStream()); must these objects to be created each time i…
Mikeel
  • 117
  • 3
  • 7
1
vote
0 answers

EOFException DataInputStream.readFully

Basically I'm helping a friend of mine out, There's a disconnection error with his game (runescape private server) and there's an error that keeps being thrown, which is DataInputStream.readFully(Unknown Source) at…
Snooperal
  • 11
  • 2
1
vote
1 answer

Java: Prevent Socket DataInputStream from throwing EOFException

My client/server application currently keeps opening and closing new connections every time it wants to send/receive data. I'm trying to change it so it will have one persistent connection. The problem I'm having is the socket's DataInputStream…
user489481
  • 321
  • 1
  • 4
  • 13
1
vote
1 answer

DataInputStream read not blocking

First off forgive me if I am mistaken for how blocking works, to my understanding blocking will pause the thread until it is ready, for exsample when reading user input the program will wait until the user hits return. My problem is that instead of…
user2131323
  • 105
  • 10