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

Java DataOutputStream alternative in Go

I have a few lines in Java out.write(223); out.writeBytes("something"); out.writeInt(434); So far I did not seem to find what is the alternative of Java DataOutputStream in Go and did not find similar functions to .write .writebytes. writeint. I'd…
OpenSource
  • 15
  • 4
0
votes
0 answers

File gets corrupted when sent over TCP Socket using Java Data(I/O)Stream

I am trying to send a file with Java TCP socket I/O Stream from Client to Server. I am using Data(Input|Output)Stream in this process. With every packet of file buffer, I want to send extra information (a Long) as HEADER to every buffer. I intend to…
Sabit
  • 1
  • 2
0
votes
0 answers

Case is never reached and Counter variable is counting wrong

One of my case statements is never reached when I try to call it from my Server, but I don't know if its because of the Server, the DataOutputStream or if I just made a logic mistake. If I try to call "useEffect" it always jumps to the default…
0
votes
0 answers

java DataOutputStream POST without status code check doesn't post (POST not working)

I've 'fixed' this but I don't understand why my fix works and that bothers me. The code below is supposed to an HTTP POST to a remote server. I have two lines commented out. With the two lines commented out, it appears to write to the HTTP…
Warren
  • 179
  • 2
  • 7
0
votes
0 answers

DataInputStream readUTF gives incorrect string-value

I´m a beginner at writing code that communicates with a server so I´m starting with something simple: To send a string to a server and then read it. The full code is as follows (with censored IP-address and port): public class ServerCommunication…
Isa
  • 1
  • 1
0
votes
2 answers

Sending a POST request to a server

I am trying to create my first android application that utilizes a REST api. My api is written in Node.JS and has already been tested using Postman, however, I am having trouble sending JSON data to my api. @Override protected String…
2000rs25
  • 47
  • 6
0
votes
1 answer

How would i pause Scanner from reading to broadcast a message?

I am trying to implement a client-server application. Suppose i have two files, Server.java and Client.java. I am connected with both via DataOutputStream and DatainputStream and through socket programming. The clients have multi-threading…
Harris
  • 89
  • 1
  • 7
0
votes
1 answer

why does Java DataOutputStream Class provide write() , writeInt() when all outputs the same thing

A data output stream class claims to write primitive Java data types to an output stream in a portable way.And it provides writeInt and other methods for their respective datatypes but if writeInt(65) and write(65) outputs the same data to file then…
vrooom
  • 51
  • 1
  • 11
0
votes
3 answers

Java Input and Output

Explain the difference between the outputs of the following two fragments of code for outputting an int i to a file: i) PrintWriter outfile = new PrintWriter(new FileWriter("ints.txt")); outfile.print(i); ii) DataOutputStream out = new…
Paradox
  • 353
  • 3
  • 9
  • 14
0
votes
1 answer

Java write(str.getBytes()) vs writeBytes(str)

When using DataOutputStream to push Strings, I normally do the following: DataOutputStream dout; String str; dout.write(str.getBytes()); I just came across the writeBytes() method of DataOutputStream, and my question is whether the above is…
Andy
  • 2,469
  • 1
  • 25
  • 25
0
votes
0 answers

Commands sent from Java client side gets chopped into multiple parts before received by C++ server side

I'm trying to send commands from my client side, implemented with Java, to the server side, implemented using C++, through TCP connection. The server-side code is given and tested, so I'm fairly certain that the parsing of the command is not the…
0
votes
2 answers

How to make multiple message in socket programming?

I have a project in which i make a chat server, where people(client) connect and choose a partner to chat with. However, they chat only when both clients send a message they see what the other typed. What I want is something like Whatsapp where we…
0
votes
1 answer

DataOutputStream: dos.write() in loop, Receiver receives only one data package

I have a problem with my TCP connection. I send data (a simple string) via a smartphone to a tablet by a TCP socket connection. The connection works fine and data is transmitted as expected. But when I do a loop and in every iteration dos.write() is…
baja
  • 53
  • 4
0
votes
0 answers

Read Java DataOutputStream in C++ client

All welcome. Still trying to create a video straming'a (client-server-client) application. The bottom line: There are 2 clients. 1 - the sender, 2 - the recipient. 1 sends the size of the picture, the picture itself. The server receives and sends it…
NewJunior
  • 5
  • 2
0
votes
1 answer

C++ creating stream function like ROS_INFO_STREAM(var1 << var2 <<...)

i am working with ROS and my task is to migrate existing Projects from ros1 to ros2. In ros1 stream functions like ROS_INFO_STREAM(String << variable << ...) exist but not in ros2, because they are not implemented yet in the rclcpp. My idea is to…
Steffan
  • 1
  • 2