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

DataOutputStream is sending wrong data

I would like to apologise for my english. It's not my native language. I'm trying to write simple TCP server and client. I have a problem with sending a number from client to server. Here is the code from client side: public class ConnectionHandler…
Ironus
  • 21
  • 3
2
votes
2 answers

How to serialize/deserialize with DataOutputStream and DataInputStream?

I'm trying to serialize/deserialize things with DataOutputSteam and DataInputSteam instead of ObjectInputStream/ObjectOutputStream. The serialization fails. The txt file remains empty. Of course, the test2 strings are all empty in the end (can't…
2
votes
2 answers

Send a Secret key over JAVA DataOutputStream

I am developing a FTP tool using symmetric key + RSA. I want to send my secret key to the server over dataoutputstream.How can I do this? I tried following, Client: SecretKey secretKey = en_de_cryptor.returnSecretKey(); String encodedKey =…
2
votes
2 answers

Unexpected behaviour in TCP socket connection Java Client<-> c++ server

I surfed a lot of questions on the board, about tcp sockets, big-endian and little-endian format but to me nothing apllies to my case. And I'm sorry for my bad English, I'm working on it :) I'm loosing my mind on an unexpected behaviour in a…
2
votes
2 answers

Unwanted chars written from java REST-API to HadoopDFS using FSDataOutputStream

We built a java REST-API to receive event data (like click on a buy button) and write that data to HDFS. Essentially we open streams for every host that is sending data (in JSON) or use existing ones, enrich data with a timestamp, an event name and…
Alex
  • 347
  • 3
  • 13
2
votes
0 answers

Reusing the same process for shell commands execution in Android. What is wrong?

My app uses a process in separate thread to run some commands and get the input from them: process = Runtime.getRuntime().exec("su"); out = new DataOutputStream(process.getOutputStream()); The app sends commands to the process like this: public…
miridavl
  • 261
  • 1
  • 2
  • 9
2
votes
2 answers

How to send JSON response using socket in Java

I have built a basic HTTP server and I am attempting to send a reply to a GET request. I have installed Gson as the JSON parser, but I'm not sure how to encode the response in JSON and send back to the client. Here is my code, any help is much…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
2
votes
2 answers

Using DataInputStream and DataOutputStream

I want to send several strings from A to B using the DataInputStream. I know how to send these across using .write() but I'm unsure of the best method to seperate the strings. In fact - after research, it doesn't seem as if it's possible unless I…
David Jackson
  • 31
  • 2
  • 6
2
votes
1 answer

OutputStream to DataOutputStream for bluetooth communication

I already wrote with the help of tutorials I found on the Internet a app for Android that connect to a Bluetooth device. This app used the InputStream and OutputStream object to connect and establish a connection. Because I had to transfer small…
2
votes
2 answers

Client doesn't receive output from server's DataOutputStream

I'm currently attempting to code my first client>server system to transmit packets containing strings back and forth through a network. However I'm having a problem in that the following is happening: The client sends message to the server, the…
Matthew Salsamendi
  • 294
  • 1
  • 5
  • 14
2
votes
2 answers

Equivalent for DataOutputStream of Java in Objective C

I am currently working on a Project which is in Objective C. I need to use Functions of Java class DataOutputStream like writeChars, writeLong, flush and some functions of ByteArrayOutputStream Class. Specifically, what can I use in Objective C…
user601146
2
votes
3 answers

Java primitive data type byte and class Byte

Background: I have an assignment where I'm going to pass information through sockets to a very limited extent. It can be a maximum of 10 bytes per message and I was thinking I'm gonna send just one byte (since one byte is enough to signal 256…
fast-reflexes
  • 4,891
  • 4
  • 31
  • 44
2
votes
0 answers

Why DataOutputStream loses a character?

I have a simple connection activity: package com.example.conn08; import ...; public class MainActivity extends Activity { public static Socket clientSocket; public static DataOutputStream outToServer; public static PrintWriter…
Leo
  • 3,003
  • 5
  • 38
  • 61
2
votes
2 answers

Sending file list from Server to Client in java Socket programming - PrintWriter can't send?

How can I send the file listing to client from server using Socket programming. I have used DataOutputStream and PrintWriter, both returns only one file name to Client. I know there is some problem in '\n'. But unable to solve it. Awaiting experts…
highlander141
  • 1,683
  • 3
  • 23
  • 48
1
vote
1 answer

My client will connect to the server, but thats it

Android client sends string to server. Server will acknowledge a connection from device, and on the correct port but that is it..What should happen is the string is printed on the server console. For reference, I've created the exact same client,…
Php Pete
  • 762
  • 3
  • 14
  • 29
1 2
3
17 18