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

Write and read floats from internal storage

I need to store three pairs of floats (three points coordinates) in file, then read them and compare. I tried this way: public Path loadPath() { Path path = new Path(); float x, y; try { FileInputStream fis = new…
0
votes
1 answer

Write out java vector results to file

The program is supposed to calculate Prime Numbers using vectors and write the results out to a file. When I run it, it calculates the Prime Numbers from 2-64 and prints it out onto the screen. But when I check the text file it's creating, instead…
0
votes
1 answer

Managing file bytes with DataOutput/InputStream

I have a program that will go through and create multiple different class instances. I want to write the details of each instance to a file using DataOutputStream (it's a necessary exercise, I'll look at other ways of doing this later), but the…
Benny
  • 242
  • 1
  • 5
  • 17
0
votes
2 answers

Can not read number send with DataOutputStream

this is my Client code Random rand = new Random(); int n = rand.nextInt(50) + 1; DataInputStream dis = new DataInputStream(_socket.getInputStream()); DataOutputStream dos = new DataOutputStream(_socket.getOutputStream()); dos.writeInt(n); and this…
user2328999
  • 91
  • 3
  • 12
0
votes
2 answers

Sending encrypted file over socket

I'm having some issues with sending an encrypted file over a socket (client-server communication). I think this is an issue related with the streams (more specifically the arrangement of streams seems to be rather complex, since I'm making data…
besnico
  • 253
  • 2
  • 4
  • 13
0
votes
2 answers

Write String with array as bytes to a file using DataOutputStream

I want all data of Latitude and Longitude which input by user being wrote into WriteGPSData.txt. But this code only write the last input of Latitude and Longitude. Help me solved this. import java.io.DataOutputStream; import…
nani
  • 389
  • 9
  • 32
0
votes
2 answers

Transferring a DataOutputStream

I have a program that connects client threads to a cinema through a socket. the client transfers his details (client no., required tickets) the cinema processes the request in another thread that makes sure there is enough seats available. …
David
  • 61
  • 1
  • 3
0
votes
2 answers

DataInputStream

I have this code on Server side : Server Side: ServerSocket listenTransferSocket = new ServerSocket(6000); Socket connectionTransferSocket = listenTransferSocket.accept(); DataOutputStream outTransferToClient = new…
Nicolaos
  • 1
  • 2
0
votes
1 answer

show page not found on browser request

I'm trying to show 404 page not found from server import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.ServerSocket; import java.net.Socket; public class ex1…
user1673892
  • 409
  • 2
  • 5
  • 17
0
votes
1 answer

Write DataOutputStream in ByteArray / ByteBuffer with "dynamic" size?

i ask myself if there is a nice solution for receiving data via TCP and reading the data in a DataInputStream and store the data in a bytearray of "dynamic" size. I thought about some solutions like writing in buffers and finally store it in a…
Chris Jung
  • 49
  • 1
  • 6
0
votes
2 answers

Read and write from a file in different classes without having to close the stream in java

hey everyone :] just wondering if is it possible to read and write from a file in different classes without having to close the stream and start over again? i need to use DataOutputStream and DataInputStream. i currently have 2 classes, my first…
Madde
  • 471
  • 1
  • 7
  • 22
0
votes
1 answer

DataOutputStream seems not send parameters

I trying to send POST data with DataOutputStream and get response data. I coded like this. String urlParameters = "table=page&format=xml"; out.println(urlParameters+"


"); String searchUrl =…
Minkyu Kim
  • 1,144
  • 3
  • 18
  • 43
0
votes
1 answer

Having an issue writing to DataOutputStream and reading from RandomAccessFile with a buffer

DataOutputStream lWriter = new DataOutputStream(connection.getOutputStream()); int bytesRead = 0; int offset = 0; byte[] bytes = new byte[1048576]; // read 1MB at a time RandomAccessFile f = new RandomAccessFile(xmlFile, "rw"); …
Dave
  • 1,645
  • 2
  • 23
  • 39
0
votes
2 answers

Passing ByteArrayOutputStream into the Constructor of DataOutputStream

I understand that this can be done using wrapper pattern, but i am having a hard time understanding, how does the following code work. ByteArrayOutputStream bytearray = new ByteArrayOutputStream(); DataOutputStream os = new…
ARAZA
  • 225
  • 1
  • 3
  • 10
0
votes
2 answers

Java send message thread

I wrote a game in Java with a client and server side using sockets and data input/output streams. The server side sometimes needs to send a message to all users in a "for" loop, but since writing to a socket can block I created a thread for each…
Alebre Exobrum
  • 47
  • 1
  • 1
  • 4