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
3 answers

java DataOutputStream exception

The exception is thrown in line 24 the second time I type something (after I have typed the host name) - server works right. Code import java.io.*; import java.net.*; class TCPclient { public static void main(String[] args) throws Exception { …
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
1
vote
2 answers

LeJOS: How write integer data succesfully to a file in NXT

I am working on some AI project which I am supposed to implement a controller using fuzzy logic on my NXT. In order to evaluate properly my control strategy, I have the need to track the information measured by the color sensor and the data that are…
Mudkip
  • 373
  • 6
  • 27
1
vote
5 answers

writeDouble() method of DataOutputStream is writing data in text document in encoded form

I have the following code public static void main(String aed[]){ double d=17.3; try{ DataOutputStream out=null; out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream("new.txt"))); …
prateek tomar
  • 362
  • 1
  • 12
1
vote
1 answer

Can't flush DataOutputStream in Java

I want to put a double array into DataInputStream and print it with DataOutputStream in console. I tried to convert it to byte array first. I can't flush() DataOutputStream, so it gets printed in console. System.out.print(c) works. double[] b = {…
jligeza
  • 4,544
  • 6
  • 23
  • 31
1
vote
0 answers

Client-server Java programm using sockets stucks while runnig, but works while debbuging

I have created a simple utility, that implements server and client. Server waits for incomming connection, client connects and if there are any files in folder on server - they are sending to client. I used DataInput/OutputStreams - writeUTF/readUTF…
1
vote
2 answers

Saving output to files

I currently am trying to put the values that are created through my object into a file. My output for the program works fine and my computations in another class's methods work. I would just like to save the the output of matrixApp into a file. I…
James Lockhart
  • 131
  • 1
  • 2
  • 11
1
vote
2 answers

How can I write the "word" representation of an integer to a file in Java?

Here is a sample code: File x = new File("garbage.byte"); x.createNewFile(); int i1 = 5; DataOutputStream dataOutputStream = new DataOutputStream(new…
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
1
vote
2 answers

Java OutputStream/TelnetClient can't write string longer than 1955 characters

I've had to create a client that takes requests from sockets and send them to our telnet legacy server and return the servers response. It's worked great until we recently realized that some of the commands I send are getting cut off at 1955…
Andrew
  • 175
  • 1
  • 2
  • 12
1
vote
1 answer

uploading a file with DataOutputStream doesn't display real progress

I am uploading a file from android to my webserver using the DataOutputStream with the following code: public class SnapshotUploadTask extends AsyncTask { private final File file; private final ProgressDialog…
stephanlindauer
  • 1,910
  • 2
  • 14
  • 17
1
vote
2 answers

How to serialize a java object which contains object references without serializing the objects referred to?

I am implementing B Plus Tree in java . I have a node class in which I am maintaining references to child object Nodes . Now When I serialize any node , it also serialize all the child nodes also. What I want is to serialize only that node and the…
1
vote
2 answers

Why DataoutputStream and BufferedWriter creation order is important?

I'm trying to create a simple client where at first I comunicate to a server: A filename The sequence of chunks which compose the file So for the first one I thought to use to a BufferedWriter: this choice was made since I can't use on the server…
1
vote
3 answers

Synchronize on DataOutputStream

I have gone through so many tutorials on Synchronization now that my head is spinning. I have never truly understood it :(. I have a Java server(MainServer), that when a client connects creates a new thread(ServerThread) with a…
KisnardOnline
  • 653
  • 4
  • 16
  • 42
1
vote
3 answers

Write int to file using DataOutputStream

I'm generating random ints and trying to write them down to a file. The problem is when I open the file I've created I don't find my ints but a set of symbols like squares etc... Is it a problem of encoding ? import java.io.DataOutputStream; import…
ElArbi
  • 1,145
  • 3
  • 13
  • 22
1
vote
0 answers

"java.net.SocketException: Software caused connection abort: socket write error" on streaming multidimensional array

I'm making a server application which streams a multidimensional array. But when it should start streaming, i'm getting a socket write error. Here's the code: Part 1 public class Server { ServerSocket server; DataInputStream quitDis; int…
littlegigant
  • 11
  • 1
  • 1
1
vote
0 answers

HttpURLConnection Bad Gateway: 502 error

I have a server to receive media jpg format and mp4 format. Delivery is via HttpURLConnection. As far as I understand - it's the best solution for working with http and https file transfer. Trying to work through http with this code:…