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

DataInputStream from a MappedByteBuffer

I wonder if it is possible to create DataInputStream backed by a MappedByteBuffer instance ? MappedByteBuffer buff = (initialize...); ByteArrayInputStream bis = new ByteArrayInputStream(buff.array()); This code snippet throws…
uahakan
  • 576
  • 1
  • 6
  • 23
1
vote
1 answer

Android getting UTFDataFormatException reading in UTF from text file

I'm noticing in my event logs for my Android app that I'm getting UTFDataFormatException errors. The file I am reading from is written by my app although as it stores information about user's stories, it could contain any kinds of…
odiggity
  • 4,117
  • 7
  • 34
  • 41
1
vote
1 answer

DataInputStream not reading small files

I am programming a blackberry app that reads small files stored on the device. For some reason DataInputStream will only read files that are bigger then 3kb (my estimate after a couple of test). Anyone know why this may be the case? try { …
Josh Starrett
  • 149
  • 1
  • 10
1
vote
2 answers

Step back and forth in DataInputStream in Java

I am reading a video file using DataInputStream. I am then using a byte array to read data one by one for each frame and then displaying them consecutively. My question is, what if I wanted to see a previous frame again, or a future frame for that…
Parag Goel
  • 123
  • 2
  • 14
0
votes
1 answer

read a text file android

I am trying to make the computer read a text file full of words and add it to an ArrayList. I made it work on a regular Java application, but can't get it to work on Android. Can someone help me out? try { FileInputStream textfl =…
steven minkus
  • 131
  • 2
  • 2
  • 14
0
votes
1 answer

How to create a DataInputStream with the content of a binary file obtained from a remote php script?

I'm calling a script that gives me a binary file (12345.cl), with binary data. The script is done, and it's working, if I paste it on the navigator I get the binary file. Now I have a problem: How I transform the response of the script into a binary…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
0
votes
1 answer

Is dataInputStream of a Socket know how to deal with multiple writings to it?

I am developing a Net game, in general: I have a server which launch a serverThread for each client that has connected to it. Its purpose is to listen to messages from the specific client and to process it on the server. Also for each client that…
JavaSa
  • 5,813
  • 16
  • 71
  • 121
0
votes
1 answer

java network- programming, trying to write a server but not working

I am trying to write a server that accepts files and write it in certain directory using DataInputStream and BufferedInputStream. The server gets 'user name(string)' 'number of files(int)' 'file name(string)' 'size of each file(long)' and 'contents…
in His Steps
  • 3,075
  • 6
  • 30
  • 38
0
votes
3 answers

Fell into infinite loop while receiving file using datainputstream and bufferedinputstream

I am trying to build a server program that receives file from client using DataInputStream and BufferedInputStream. Here's my code and it falls into infinite loop, I think it's because of not using available() but I am not really…
0
votes
1 answer

Receive file info using DataInputStream and write it

I am trying to receive a file that client sends using DataInputStream and write it into file. (Client sends the file using DataInputStream write(byte[], len, off) method) Here's how I am trying to do, but it does not receive full data. InputStream…
in His Steps
  • 3,075
  • 6
  • 30
  • 38
0
votes
1 answer

DataInputStream stuck on readFully

I have a BluetoothSocket that I am reading data from, using a separate Thread process from the GUI. I wrap the InputStream in DataInputStream so I can do use a a readFully(..) to wait for a specified amount of data. I can run this code for about…
JPM
  • 9,077
  • 13
  • 78
  • 137
0
votes
0 answers

DataInputStream.readFully() doesn't have data to read when reading an HTTP POST request with no Expect: 100-continue

I have a simple HTTP server that must manually implement handling for POST requests that send in a file. The problem is, if the header does not include an Expect: 100-continue and thus sends the HTTP body along with the headers, when I call…
0
votes
0 answers

How to properly receive data from input/output streams in Multithreaded Server Client FTP

I'm trying to create a Multithreaded Server Client FTP that will allow the client to perform certain tasks in the background (EX: put test.txt) can run in the background and then the client can input another command. So far, I have a listener thread…
Diana
  • 1
  • 1
0
votes
1 answer

Input/OutputStream between System.in and System.out - problem with readUTF() and writeUTF()

I'm trying to set up a very simple communication flow between System.in and System.out in Java, in order to understand how streams work. I'm using DataInputStream for System.in and DataOutputStream for System.out, and they're communicating through…
0
votes
2 answers

Use junit to test reading from text and binary files and writing to text and binary files

I wrote a Course class that has constructors that read from text and binary files and has methods to write to text and binary files. How do I write a junit test to test this class? see code below: import java.io.DataInputStream; import…
trs
  • 2,454
  • 13
  • 42
  • 61