Questions tagged [dataoutputstream]

A mechanism for writing abstract data to a stream

A DataOutputStream is a mechanism for writing any abstract data to a stream, regardless of the type of the data. A stream is usually comprised of data to write to a local file, or data being transmitted to a remote server over a network protocol such as HTTP or FTP.

An DataOutputStream is abstract, and doesn't describe the type of data that is being written. Typically, if you are able to, you would implement one of the subclasses instead, such as FileOutputStream, which more appropriately describes the type of data being handled, and provides additional methods appropriate for that data type.

257 questions
1
vote
2 answers

can I send same HTTP request with same HttpURLConnection multiple times?

In order to send a string data to the server once, I do as below: Make “HttpURLConnection” to my URL address and open it Set the required headers for the connection I Set setDoOutput to True new a DataOutputStream from my connection and finally…
1
vote
2 answers

Weird outputs while using DataOutputStream

I'm using DataOutputStream of Java IO in order to write to a file but when I execute the program, I don't get the correct output, instead, I get weird characters. -Although I have noticed that only writing strings using the writeUTF(String str)…
bremmS
  • 277
  • 1
  • 6
  • 13
1
vote
0 answers

DataInputStream not getting the right value

I'm trying to setup a server-client file transfer where one user sends a file to the server, and the server sends that file to another user (users in this case are instances of the Client.java class). From the first client to the server, everything…
1
vote
0 answers

java.io.ioexception write failed ebadf (bad file descriptor)

I am trying to make a serial communication with an android device but when I run the write command I get the following error : java.io.IOException: write failed EBADF (Bad file number) public void write(boolean isAscii, String cmd) { …
1
vote
1 answer

Inconsistent results from write, then read with byte array and DataOutputStream

Short Version: I write an 8 byte, byte array filled with random bytes to disk using a DataOutputStream, and then read it back in with a DataInputStream in another method. The data does not appear to be the same. Where should I start looking for…
Kurt
  • 157
  • 5
1
vote
1 answer

Client-server application file transfer

I am currently trying to design a client-server application, something like this: the user connects to the server and when the authentication is OK the server send to the user some files. The problem is that those files are written in a single file…
Ionut Ungureanu
  • 380
  • 3
  • 9
  • 25
1
vote
1 answer

dataOutput.writeUTF Python Equivalent

I`m trying a socket connection between Java and Python. Are a dataOutput.writeUTF equivalent in Python to send and receive data? Here`s an example of my code. received = client.recv(1024) print(received) toSend = input() client.send(toSend)
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
1 answer

Sending command to a device over Bluetooth by writing to DataOutputStream

I'm trying to send a command to a device over my Bluetooth RFCOMM socket Connection. -Connection is successful. -As soon as it gets connected i tried reading the DataInputStream and i continuously get data from the device. -My problem is i'm trying…
m4n07
  • 2,267
  • 12
  • 50
  • 65
1
vote
2 answers

Sending an int in java. Sometime causing an Exception?

ok im sending an int from one java program to another (on same computer at the minute). However, sometimes I'm getting an exception and it wont connect: Exception in thread "main" java.net.ConnectException: Connection refused: connect at…
user650309
  • 2,639
  • 7
  • 28
  • 47
1
vote
1 answer

reference variable DataOutputStream and FileOutputStream

Given this sample of code: { try (DataOutputStream dataOut= new DataOutputStream (new FileOutputStream ("testdata") please, let me know, is dataOutput a reference variable also for FileOutputStream since it somehow works? Otherwise, why to put in a…
1
vote
1 answer

Why does ObjectOutputStream write 14 bytes instead of 8 with DataOutputStream?

The same method (writeInt()) in ObjectOutputStream and DataOutputStream writes different data? Isn't it supposed to be equal for primitive types? // Output: 14 bytes file ObjectOutputStream out = new ObjectOutputStream(new…
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
0 answers

How to encode data in URL and upload file on same connection?

I want to upload file to server from the device and send some data as well on the same request by encoding in the url, i have tried but it is not working. What i am doing wrong and How can we do it? HttpURLConnection conn = null; DataOutputStream…