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

Why I get a 0kb file when I use datainputstream, java, android?

I'm really confused about why I get a 0kb file when I use that code showing below. As the instruction of Java website about this class, I should be worked. but... And I want to generate a sine wave and output its result in to a txt fill in double.…
MarvinC
  • 89
  • 1
  • 1
  • 8
0
votes
1 answer

jTextArea saves only first line of text in text file using BufferedReader?

I am trying to save the multiple line output in a text file from my jTextArea(named as "outputarea" in a code) to my desired path, Everything is OK but the file being saved do not contain the whole output, but only first line oof text. I am using…
0
votes
1 answer

Inconsistent I/O when reading int from DataInputStream

I have a client-server topology in which the client asks for a listing of the directories or files in the current working directory on the server, and the server replies with the appropriate information. See client…
Dreadlockyx
  • 181
  • 1
  • 11
0
votes
0 answers

Why is DataOutputStream in java not working as expected?

I am learning about file IO in java, and wanted to test this, but I am not sure why I am getting weird results. Here is the code. import java.io.FileOutputStream; import java.io.IOException; import java.io.DataOutputStream; public class driver { …
theprogrammer
  • 1,698
  • 7
  • 28
  • 48
0
votes
1 answer

Close CipherOutputStream without DataOutputStream & Socket

I'm working with Cipher where connection is being held on the underlying socket and dataoutputstream. Now according to CipherOutputStream documentation, that in order to let the final block out of the encryptor, we need to call close(). So using it…
androizer
  • 77
  • 9
0
votes
1 answer

What should I use on platforms pre-Kitkat

I am trying to send a POST to a URL and then read the response. HttpURLConnection conn = (HttpURLConnection)…
the_gesslar
  • 379
  • 3
  • 13
0
votes
1 answer

DataOutputStream and DataInputStream miscommunication

So I have a client/server game and each time a client makes a move the game outputs to the DataOutputStream and is received by a DataInputStream, the first message is a join message which tells the server the users name (this message is properly…
Mike Rinos
  • 43
  • 1
  • 9
0
votes
1 answer

DataOutputStream to Array

Is there any way to write DataOutputStream content to an Array or a String regardless which type of data it contains? DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(String dataPath))); Thanks
Jürgen K.
  • 3,427
  • 9
  • 30
  • 66
0
votes
1 answer

Exception with DataOutputStream but not PrintWriter

I have developed a basic java client/server using sockets. Using PrintWriter, everything works as expected. But, if I change the server output method to DataOutputStream, the InputStream on the client is 0 length, and it eventually times…
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
0
votes
2 answers

How can I make DataOutputStream write a bool or integer to a txt file?

public static void outputFile() { HabitItem it; try { File path = new File("output.txt"); FileOutputStream fout = new FileOutputStream(path); DataOutputStream dos = new DataOutputStream(fout); while…
Cameron
  • 2,805
  • 3
  • 31
  • 45
0
votes
4 answers

My .dat file can't display double number

I created my sales.dat with these code: public static void main(String[] args) throws IOException { DataOutputStream output = new DataOutputStream (new FileOutputStream("E:/HOMEWORK/OOP/OOP-java/src/week2/sales.dat")); …
MInh Đinh
  • 11
  • 2
0
votes
1 answer

What is the best way of java socket server for TCP using by vert.x, netty, socket.io, or socketserver?

I don't know what I have to use. It's my first time to make Socket(TCP) Server. I'll use java and eclipse platform. I'm considering to develop Socket Server on the Eclipse. This server will be covered 500-2,000 client's connections. (normally 1,000…
0
votes
2 answers

Java Static NonStatic issues - how to create a new instance without starting the program again

I am making a game proxy in Java, I've done it but I have a problem where it seems that the client packets aren't getting sent to the server and vice versa. I've posted 4 classes: Proxy, Client, Server and Send. The Proxy class just starts…
Shivam Paw
  • 203
  • 3
  • 14
0
votes
1 answer

Socket DataOutputStream writeInt() method NullPointerException

I'm trying to send serialize class object on the server side. First I serialize object in byte array, then I take array length and send lenght as integer and send array on the srever side. But programm fold with NullPointerException in stacktrace.…
Denis Makovsky
  • 460
  • 7
  • 22
0
votes
1 answer

Java Webserver not responding

Goal: My goal with this code is to create a simple web server that can handle multiple clients, and that will respond with the html to say "hi" when the client requests it. Code: Here's test number one. It only can handle one client once: import…
Evan
  • 11
  • 2