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) {