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

Do sockets clean part of their buffer every time I read a segment of the incoming message?

I've started working with Java and sockets and I'm having some problems with DataInputStream. I'm receiving a telegram which contains the message length in the first 4 bytes of the message itself, so at the first iteration I just read this memory…
Davide3i
  • 1,035
  • 3
  • 15
  • 35
-2
votes
3 answers

Whats wrong with InputStreamReader here?

I have created a Java Shopping Cart App. I have used InputStreamReader class for it. But its showing strange behavoiur. I have already tried Scanner class and Data Input Stream class. But they they do not seem to be fit for this app. Can anyone…
-2
votes
1 answer

Which one .readUTF method in DataInputStream will proceed first?

If I call two .readUTF methods of one DataInputStream object in two different streams, which one will read information first? Which was called first, or which was called second?
-2
votes
1 answer

Inquiry about method readUTF() of class DataInputStream

Does anybody know how it works under the hood? I have read this API, however it's not that clear. Could anybody put it down in a more simplistic way? Thanks in advance.
Rollerball
  • 12,618
  • 23
  • 92
  • 161
-2
votes
3 answers

Program to add two integer numbers read from a text file and displaying results on console

Even after lots of trial and error, I am unable to figure out how to write a java program that adds 2 integers (read from a text file) and displays addition result on the console. I tried using FileInputStream, DataInputStream classes ... Example…
Salman
  • 109
  • 2
  • 4
  • 10
-3
votes
1 answer

input string from a file and compare the input string

I want to input strings from a file and check whether each of the string match a given string, but I couldn't make it. Thanks in advance for helping. My code is as following: import java.util.*; import java.io.*; import…
Jess
  • 71
  • 3
  • 10
-3
votes
1 answer

Different reading binary files in java / c++

My task is to read binary compressed files using JAVA. there is a difference between reading as C++ and JAVA. i don't know what the problem is when i read it with JAVA. Please let me know the problem of JAVA code that i wrote. please, help.. here…
-3
votes
3 answers

DataInputStream and DataOutputStream

I made my own bufferedwriter which works. But I don't know if it really does? I made a bufferedreader when I logout I have (200 coins) and when I login I get (545453 coins) or other amount I am sure it's the bufferedwriter, PLEASE HELP! public…
-4
votes
1 answer

readLong() return wrong value

I use the function of "DataInputStream" called "readLong()" to read value from a file end with ".txt". This file was edited in advance. I want to get the correct value "123456789", but the answer is "3544952156018063160" DataInputStream di = new…
1 2 3
22
23