Reputation: 4070
I'm trying to transfer strings from my server to my client and I'm trying to find an explanation why when I'm using PrintWriter
in my server the client receives the string while when I'm using BufferedWriter
the client doesn't receive the string.
In my client I have the next readers/writers:
out=new PrintWriter(s.getOutputStream());
in=new BufferedReader(new InputStreamReader(s.getInputStream()));
In my main I'm receiving data from server with the next call:
String sol=in.readLine();
In my server I'm sending data with the next call (os is an outputStream that I get in my function):
PrintWriter out= new PrintWriter(os);
out.write("test");
out.flush();
While when I use BufferedWriter
it doesn't send data to the client (or the client can't receive it?) "
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os));
out.append("test"); // tried also using out.write
out.flush();
Upvotes: 1
Views: 344
Reputation: 4070
On my server side Bufferwriter doesn't add "\n" to the end of the string while in my client side I'm trying to read a line with inputstream. Printwriter adds "\n" in the method println. Thanks to @EdwinDalorzo for the help.
Upvotes: 1