Index: trunk/modules/luni/src/main/java/java/io/DataOutputStream.java =================================================================== --- trunk/modules/luni/src/main/java/java/io/DataOutputStream.java (revision 429584) +++ trunk/modules/luni/src/main/java/java/io/DataOutputStream.java (working copy) @@ -157,6 +157,9 @@ * @see DataInput#readFully(byte[],int,int) */ public final void writeBytes(String str) throws IOException { + if (str.length() == 0) { + return; + } byte bytes[] = new byte[str.length()]; for (int index = 0; index < str.length(); index++) bytes[index] = (byte) str.charAt(index); Index: trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java =================================================================== --- trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java (revision 429584) +++ trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java (working copy) @@ -151,7 +151,7 @@ /** * @tests java.io.DataOutputStream#writeBytes(java.lang.String) */ - public void test_writeBytesLjava_lang_String() { + public void test_writeBytesLjava_lang_String() throws IOException { // Test for method void // java.io.DataOutputStream.writeBytes(java.lang.String) try { @@ -166,6 +166,8 @@ } catch (IOException e) { fail("Exception during writeBytes test : " + e.getMessage()); } + // regression test for HARMONY-1101 + new DataOutputStream(null).writeBytes(""); } /**