diff --git a/core/src/main/java/com/threerings/io/ObjectInputStream.java b/core/src/main/java/com/threerings/io/ObjectInputStream.java index 10d110d72..1f3fdbac8 100644 --- a/core/src/main/java/com/threerings/io/ObjectInputStream.java +++ b/core/src/main/java/com/threerings/io/ObjectInputStream.java @@ -24,11 +24,9 @@ package com.threerings.io; import java.util.List; import java.util.Map; -import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -319,13 +317,7 @@ public class ObjectInputStream extends DataInputStream // read precisely that many into a buffer byte[] bbuf = new byte[utflen]; in.read(bbuf); - - // decode the UTF-8 stream into a character buffer - char[] cbuf = new char[utflen]; - int read = new InputStreamReader(new ByteArrayInputStream(bbuf), "UTF-8").read(cbuf); - - // create and return the string given the number of decoded characters - return String.copyValueOf(cbuf, 0, read); + return new String(bbuf, "UTF-8"); } @Override diff --git a/core/src/main/java/com/threerings/io/ObjectOutputStream.java b/core/src/main/java/com/threerings/io/ObjectOutputStream.java index b1f2b1df1..993e515c8 100644 --- a/core/src/main/java/com/threerings/io/ObjectOutputStream.java +++ b/core/src/main/java/com/threerings/io/ObjectOutputStream.java @@ -23,11 +23,9 @@ package com.threerings.io; import java.util.Map; -import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.io.OutputStreamWriter; import com.google.common.collect.Maps; @@ -306,19 +304,9 @@ public class ObjectOutputStream extends DataOutputStream public void writeUnmodifiedUTF (String str) throws IOException { - // prepare a buffer to accept the encoded UTF-8 - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(baos, "UTF-8"); - - // do the deed - osw.write(str); - osw.flush(); - - // now that we know how many bytes we'll need, write that number to the stream - writeShort(baos.size()); - - // then finally the bytes themselves - write(baos.toByteArray()); + byte[] bytes = str.getBytes("UTF-8"); + writeShort(bytes.length); + write(bytes); } /** Used to map classes to numeric codes and the {@link Streamer} instance used to write