From 3e7e619192f88253f441f9c2d538eeb6d9e72cb6 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Fri, 10 Jan 2014 18:42:31 +0000 Subject: [PATCH] git-svn-id: svn://imanolbarba.net/PAD@59 c2ee353e-ed0d-4329-bf56-03aec153487f --- JChatServerV2/src/pad/prac2/MySocket.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/JChatServerV2/src/pad/prac2/MySocket.java b/JChatServerV2/src/pad/prac2/MySocket.java index 36f8d98..af59bf7 100644 --- a/JChatServerV2/src/pad/prac2/MySocket.java +++ b/JChatServerV2/src/pad/prac2/MySocket.java @@ -7,6 +7,7 @@ import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; +import java.nio.charset.Charset; public class MySocket extends Socket { @@ -37,7 +38,7 @@ public class MySocket extends Socket try { output = super.getOutputStream(); - input = new BufferedReader(new InputStreamReader(super.getInputStream(),"UTF-8")); + input = new BufferedReader(new InputStreamReader(super.getInputStream())); } catch(IOException ioExc) { @@ -67,7 +68,7 @@ public class MySocket extends Socket public void write(String str) throws IOException { - output.write(str.getBytes()); + output.write(str.getBytes("UTF-8")); } public String read(int bytes) @@ -76,7 +77,8 @@ public class MySocket extends Socket try { input.read(buffer, 0, bytes); - return new String(buffer); + byte[] bytesRead = new String(buffer).getBytes("UTF-8"); //Cosas del Unicode, por culpa del **** Java + return new String(bytesRead,"UTF-8"); } catch(IOException ioExc) { -- libgit2 0.22.2