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

Creating ObjectInputStream from Socket throwing EOFException

I will try to put it simply. Class constructor 'B' is recieving a socket as parameter, it is coming from class 'A'. In A, the socket is used for I/O using DataInputStream and DataOutputStream. Neither the socket nor the streams are been closed by…
-1
votes
1 answer

Is Java's DataInputStream's readByte() faster than readInt()?

Background: I'm currently creating an application in which two Java programs communicate over a network using a DataInputStream and DataOutputStream. Before every communication, I'd like to send an indication of what type of data is being sent, so…
-1
votes
2 answers

what is difference between readInt() and available() function of DataInputOutStream in java

I need to know how to behave readInt() and available() function to read data stream e.g:- [{"frame_id":"48","get_person":true,"type":"get_person","sensor_type":"mjpeg","data_size":41,"engine_id":"rtface"}{"type": "GET_PEOPLE_RESP", "people":…
HWJ
  • 87
  • 2
  • 9
-1
votes
1 answer

Server Socket reads Client message indefinitely in Java

In my simple Java Client-Server program, when sending a message to the server and reading it there, readInt() reads indefinitely, making the program stick there. I made sure I was only sending and receiving an int, nothing else, as you can tell by…
-1
votes
2 answers

How to read DataInputStream until the end without needing to catch an EOFException?

Suppose we have some binary data byte[] data that only contains Integers. If I wanted to read this data utilizing a DataInputStream, the only approach I can come up with is the following: DataInputStream in = new DataInputStream(new…
Michael Schnerring
  • 3,584
  • 4
  • 23
  • 53
-1
votes
2 answers

Converting java.net.Socket.getInputStream() to byte[] showing large delay

I have designed a Java Client class that is required to send a byte[] array to a Java Server class via a socket. Here is my code: ByteArrayClient.java import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import…
Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39
-1
votes
1 answer

Stream of short[]

Hi I need to calculate the entropy of order m of a file where m is the number of bit (m <= 16). So: H_m(X)=-sum_i=0 to i=2^m-1{(p_i,m)(log_2 (p_i,m))} So, I thought to create an input stream to read the file and then calculate the probability of…
user6008748
-1
votes
3 answers

Problems with catching dataInputStream.readUTF();

I'm making a Java program to make my computer a server to communicate with my smartphone over WiFi. Therefore I use the Socket class, as can be seen in the code below (based on Android-er): package main; import java.io.BufferedReader; import…
Bram
  • 21
  • 1
  • 4
-1
votes
2 answers

How to get String from DataInputStream in Java?

I am working on an application consisting of sockets. It needs to transfer a String value from the client(android device) to the server(my PC running Ubuntu). On the server side code, I need to store the value being transferred via socket in a…
priyankvex
  • 5,760
  • 5
  • 28
  • 44
-1
votes
2 answers

How to read and write integer -1 into DataOutputStream

I want to read and write some values into the DataOutputStream, but sometimes the value is int -1. I am able to write this value but while reading getting EOFException, I think the value -1 its reading a EOF. Can someone help me to figure out how…
AndroidDev
  • 888
  • 3
  • 13
  • 27
-1
votes
1 answer

Program stop working when try to read input stream

I have a Java Server and one(or more) Android Clients. For now I want them to communicate simply with strings. When i write from android I can get the data in Java Server, but when I try to get the answer from server the Android application stop…
-1
votes
1 answer

writing files / large amount of bytes fails

I am writing files / large amount of bytes over socket. But lets say I am writing bytes. I do this; //Connection.data is a dataoutputstream byte[] a = new byte[filelength]; //load file into the array //write file for (int i = 0; i < a.length; i++)…
-1
votes
1 answer

Cannot read a byte array from socket

i am writing an application where i transfer a byte array over a socket in java. The generation of byte array at the client end is as follows: String vote = br.readLine(); // the data that i now encrypt using RSA PublicKey pubKey =…
Amit Vig
  • 175
  • 2
  • 12
-2
votes
2 answers

Java : know how much bytes were read by ImageIO.read() (and maybe other similar methods)

i am making a java program that reads data from a binary stream (using a DataInputStream). Sometimes during this process i need to read a data chunk, however the method (which i cannot modify) that reads it will stop before reaching the end of the…
TwilCynder
  • 33
  • 6
-2
votes
1 answer

How to send a valid result of an arithmetic operation through DataOutputStream

I have a subprocess class that calculate the sum of two integers and then put it in a DataOutputStream: public class SubProcess { public static void main(String[] args) throws IOException { DataInputStream in = new…
Moh Lamine
  • 72
  • 1
  • 9
1 2 3
22
23