From 90a6d78a3c9f5b5df30032ac5eed33c96ba4d321 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 22 Feb 2010 20:26:31 +0000 Subject: [PATCH] Revert. We'll roll something together when Zell's not trying to release. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6042 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/io/ObjectInputStream.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/io/ObjectInputStream.java b/src/java/com/threerings/io/ObjectInputStream.java index 96e18f3d7..0c1b1f818 100644 --- a/src/java/com/threerings/io/ObjectInputStream.java +++ b/src/java/com/threerings/io/ObjectInputStream.java @@ -24,15 +24,14 @@ package com.threerings.io; import java.util.ArrayList; import java.util.HashMap; +import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import com.google.common.base.Charsets; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.common.io.LineReader; import com.samskivert.util.StringUtil; @@ -315,10 +314,18 @@ public class ObjectInputStream extends DataInputStream public String readUnmodifiedUTF () throws IOException { - if (_reader == null) { - _reader = new LineReader(new InputStreamReader(this, Charsets.UTF_8)); - } - return _reader.readLine(); + // find out how many raw bytes of UTF8 data there is + int utflen = readUnsignedShort(); + // 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); } @Override @@ -347,8 +354,6 @@ public class ObjectInputStream extends DataInputStream /** An optional set of class name translations to use when unserializing objects. */ protected HashMap _translations; - protected LineReader _reader; - /** Used to activate verbose debug logging. */ protected static final boolean STREAM_DEBUG = false; }