@@ -0,0 +1,2305 @@
+/*%0A * Copyright (c) 2000-2004 by JetBrains s.r.o. All Rights Reserved.%0A * Use is subject to license terms.%0A */%0Apackage com.intellij.compiler;%0A%0Aimport com.intellij.util.io.IOUtil;%0Aimport junit.framework.TestCase;%0A%0Aimport java.io.*;%0A%0A/**%0A * @author Eugene Zhuravlev%0A *         Date: Nov 3, 2006%0A */%0Apublic class IOUtilTest extends TestCase %7B%0A%0A  private static interface IO %7B%0A    void save(String str, DataOutput out) throws IOException;%0A    String load(DataInput in) throws IOException;%0A  %7D%0A%0A  private static final IO COMPILER_IO_UTIL_SAVE = new IO() %7B%0A    public void save(String str, DataOutput out) throws IOException %7B%0A      CompilerIOUtil.writeString(str, out);%0A    %7D%0A    public String load(DataInput in) throws IOException %7B%0A      return CompilerIOUtil.readString(in);%0A    %7D%0A  %7D;%0A%0A  private static final IO IO_UTIL_SAVE = new IO() %7B%0A    public void save(String str, DataOutput out) throws IOException %7B%0A      IOUtil.writeString(str, out);%0A    %7D%0A    public String load(DataInput in) throws IOException %7B%0A      return IOUtil.readString(in);%0A    %7D%0A  %7D;%0A%0A%0A  public void testReadWriteCompilerIOUtil() throws IOException %7B%0A    final String strL = Character.toString('%5Cu0141'); %0A    assertEquals(strL, load(save(strL, COMPILER_IO_UTIL_SAVE), COMPILER_IO_UTIL_SAVE));%0A%0A    final String strA = Character.toString('%5Cu00C4');%0A    assertEquals(strA, load(save(strA, COMPILER_IO_UTIL_SAVE), COMPILER_IO_UTIL_SAVE));%0A  %7D%0A%0A  public void testReadWriteIOUtil() throws IOException %7B%0A    final String strL = Character.toString('%5Cu0141');%0A    assertEquals(strL, load(save(strL, IO_UTIL_SAVE), IO_UTIL_SAVE));%0A%0A    final String strA = Character.toString('%5Cu00C4');%0A    assertEquals(strA, load(save(strA, IO_UTIL_SAVE), IO_UTIL_SAVE));%0A  %7D%0A%0A%0A  private static byte%5B%5D save(String str, IO io) throws IOException %7B%0A    final ByteArrayOutputStream os = new ByteArrayOutputStream();%0A    final DataOutputStream out = new DataOutputStream(os);%0A    try %7B%0A      io.save(str, out);%0A    %7D%0A    finally %7B%0A      out.close();%0A    %7D%0A    return os.toByteArray();%0A  %7D%0A%0A  private static String load(byte%5B%5D bytes, IO io) throws IOException %7B%0A    final DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));%0A    try %7B%0A      final String str = io.load(in);%0A      return str;%0A    %7D%0A    finally %7B%0A      in.close();%0A    %7D%0A%0A  %7D%0A%7D%0A

correct conversion from bytes to char + tests