In the Setup() method we write to the stream using
fos.write(fileString.getBytes());
but getBytes() converts the string into the native encoding for the
platform, so when we read the data back in we want to convert it back
from the native encoding before we try to do any comparison with UTF-8
chars.
Regards,
Oliver
Nathan Beyer wrote:
I'm curious about this change. There's no declaration of UTF-8 as the
encoding, how is that getting set? AIUI the InputStreamReader will use
the default encoding of the operating system.
-Nathan
On Thu, Apr 30, 2009 at 10:54 AM, <[email protected]> wrote:
Author: odeakin
Date: Thu Apr 30 15:54:29 2009
New Revision: 770302
URL: http://svn.apache.org/viewvc?rev=770302&view=rev
Log:
Minor change to ensure we read test data back in UTF-8.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
URL:
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java?rev=770302&r1=770301&r2=770302&view=diff
==============================================================================
---
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
(original)
+++
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
Thu Apr 30 15:54:29 2009
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStreamReader;
import java.io.FileOutputStream;
import java.io.FilePermission;
import java.io.IOException;
@@ -109,9 +110,9 @@
* @tests java.io.FileInputStream#read()
*/
public void test_read() throws IOException {
- is = new FileInputStream(fileName);
- int c = is.read();
- is.close();
+ InputStreamReader isr = new InputStreamReader(new
FileInputStream(fileName));
+ int c = isr.read();
+ isr.close();
assertTrue("read returned incorrect char", c == fileString.charAt(0));
}
--
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU