WriteUTF.java revision 2362
183N/A/*
268N/A * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
268N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
268N/A *
268N/A * This code is free software; you can redistribute it and/or modify it
268N/A * under the terms of the GNU General Public License version 2 only, as
268N/A * published by the Free Software Foundation.
268N/A *
268N/A * This code is distributed in the hope that it will be useful, but WITHOUT
268N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
268N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
268N/A * version 2 for more details (a copy is included in the LICENSE file that
268N/A * accompanied this code).
268N/A *
268N/A * You should have received a copy of the GNU General Public License version
268N/A * 2 along with this work; if not, write to the Free Software Foundation,
268N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
268N/A *
268N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
268N/A * or visit www.oracle.com if you need additional information or have any
268N/A * questions.
268N/A */
268N/A
183N/A/* @test
183N/A @bug 4260284
183N/A @summary Test if DataOutputStream will overcount written field.
183N/A*/
183N/A
183N/Aimport java.io.*;
183N/A
183N/Apublic class WriteUTF {
183N/A public static void main(String[] args) throws Exception {
183N/A ByteArrayOutputStream baos = new ByteArrayOutputStream();
183N/A DataOutputStream dos = new DataOutputStream(baos);
268N/A dos.writeUTF("Hello, World!"); // 15
2157N/A dos.flush();
2157N/A if (baos.size() != dos.size())
183N/A throw new RuntimeException("Miscounted bytes in DataOutputStream.");
183N/A }
183N/A}
183N/A