Occam's razor.
These String methods have been around since jdk1.1...
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user